Part Number Hot Search : 
SRC12 1H683J FT4013 2SC6145 MRA0610 27C25 SI4368DY 10H158
Product Description
Full Text Search
 

To Download HD6432148XXXTE Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  hitachi single-chip microcomputer h8s/2148 series h8s/2144 series h8s/2148f-ztat?, h8s/2144f-ztat?, h8s/2142f-ztat? h8s/2148 hd6432148w, hd6432148, hd64f2148 h8s/2147 hd6432147w, hd6432147 h8s/2144 hd6432144, hd64f2144 h8s/2143 hd6432143 h8s/2142 hd6432142, hd64f2142r hardware manual ade-602-125a rev. 2.0 3/9/99 hitachi, ltd. 1997
notice when using this document, keep the following in mind: 1. this document may, wholly or partially, be subject to change without notice. 2. all rights are reserved: no one is permitted to reproduce or duplicate, in any form, the whole or part of this document without hitachis permission. 3. hitachi will not be held responsible for any damage to the user that may result from accidents or any other reasons during operation of the users unit according to this document. 4. circuitry and other examples described herein are meant merely to indicate the characteristics and performance of hitachis semiconductor products. hitachi assumes no responsibility for any intellectual property claims or other problems that may result from applications based on the examples described herein. 5. no license is granted by implication or otherwise under any patents or other rights of any third party or hitachi, ltd. 6. medical applications: hitachis products are not authorized for use in medical applications without the written consent of the appropriate officer of hitachis sales company. such use includes, but is not limited to, use in life support systems. buyers of hitachis products are requested to notify the relevant hitachi sales offices when planning to use the products in medical applications.
i contents contents ..... .....................................................................................................i preface ....... .....................................................................................................1 section 1 overview ........................................................................................3 1.1 overview ......................................................................................................................... 3 1.2 internal block diagram.................................................................................................... 8 1.3 pin arrangement and functions ....................................................................................... 10 1.3.1 pin arrangement................................................................................................. 10 1.3.2 pin functions in each operating mode ............................................................... 12 1.3.3 pin functions ...................................................................................................... 20 section 2 cpu................................................................................................27 2.1 overview ......................................................................................................................... 27 2.1.1 features .............................................................................................................. 27 2.1.2 differences between h8s/2600 cpu and h8s/2000 cpu ................................... 28 2.1.3 differences from h8/300 cpu ............................................................................ 29 2.1.4 differences from h8/300h cpu ......................................................................... 29 2.2 cpu operating modes ..................................................................................................... 30 2.3 address space.................................................................................................................. 35 2.4 register configuration ..................................................................................................... 36 2.4.1 overview ............................................................................................................ 36 2.4.2 general registers................................................................................................ 37 2.4.3 control registers ................................................................................................ 38 2.4.4 initial register values ........................................................................................ 39 2.5 data formats.................................................................................................................... 40 2.5.1 general register data formats ........................................................................... 40 2.5.2 memory data formats ........................................................................................ 42 2.6 instruction set.................................................................................................................. 43 2.6.1 overview ............................................................................................................ 43 2.6.2 instructions and addressing modes..................................................................... 44 2.6.3 table of instructions classified by function ....................................................... 46 2.6.4 basic instruction formats ................................................................................... 55 2.6.5 notes on use of bit-manipulation instructions.................................................... 56 2.7 addressing modes and effective address calculation...................................................... 57 2.7.1 addressing mode................................................................................................ 57 2.7.2 effective address calculation............................................................................. 61
ii 2.8 processing states.............................................................................................................. 64 2.8.1 overview ............................................................................................................ 64 2.8.2 reset state.......................................................................................................... 65 2.8.3 exception-handling state ................................................................................... 66 2.8.4 program execution state..................................................................................... 67 2.8.5 bus-released state ............................................................................................. 67 2.8.6 power-down state .............................................................................................. 67 2.9 basic timing ................................................................................................................... 68 2.9.1 overview ............................................................................................................ 68 2.9.2 on-chip memory (rom, ram)......................................................................... 68 2.9.3 on-chip supporting module access timing....................................................... 70 2.9.4 external address space access timing .............................................................. 71 section 3 mcu operating modes .................................................................. 73 3.1 overview ......................................................................................................................... 73 3.1.1 operating mode selection .................................................................................. 73 3.1.2 register configuration........................................................................................ 74 3.2 register descriptions ....................................................................................................... 74 3.2.1 mode control register (mdcr)......................................................................... 74 3.2.2 system control register (syscr)...................................................................... 75 3.2.3 bus control register (bcr) ............................................................................... 77 3.2.4 serial timer control register (stcr) ................................................................ 78 3.3 operating mode descriptions........................................................................................... 79 3.3.1 mode 1 ............................................................................................................... 79 3.3.2 mode 2 ............................................................................................................... 79 3.3.3 mode 3 ............................................................................................................... 80 3.4 pin functions in each operating mode ............................................................................ 80 3.5 memory map in each operating mode ............................................................................ 81 section 4 exception handling........................................................................ 89 4.1 overview ......................................................................................................................... 89 4.1.1 exception handling types and priority............................................................... 89 4.1.2 exception handling operation............................................................................ 90 4.1.3 exception sources and vector table................................................................... 90 4.2 reset................................................................................................................................ 92 4.2.1 overview ............................................................................................................ 92 4.2.2 reset sequence................................................................................................... 92 4.2.3 interrupts after reset........................................................................................... 94 4.3 interrupts ......................................................................................................................... 95 4.4 trap instruction ............................................................................................................... 96 4.5 stack status after exception handling ............................................................................. 97 4.6 notes on use of the stack ................................................................................................ 98
iii section 5 interrupt controller.........................................................................99 5.1 overview ......................................................................................................................... 99 5.1.1 features .............................................................................................................. 99 5.1.2 block diagram.................................................................................................... 100 5.1.3 pin configuration................................................................................................ 101 5.1.4 register configuration........................................................................................ 101 5.2 register descriptions ....................................................................................................... 102 5.2.1 system control register (syscr)...................................................................... 102 5.2.2 interrupt control registers a to c (icra to icrc)............................................ 103 5.2.3 irq enable register (ier) ................................................................................. 104 5.2.4 irq sense control registers h and l (iscrh, iscrl)...................................... 105 5.2.5 irq status register (isr) ................................................................................... 106 5.2.6 keyboard matrix interrupt mask register (kmimr) .......................................... 107 5.2.7 keyboard matrix interrupt mask register (kmimra) ....................................... 108 5.2.8 address break control register (abrkcr)....................................................... 110 5.2.9 break address registers a, b, c (bara, barb, barc).................................. 111 5.3 interrupt sources.............................................................................................................. 112 5.3.1 external interrupts .............................................................................................. 112 5.3.2 internal interrupts ............................................................................................... 114 5.3.3 interrupt exception vector table........................................................................ 114 5.4 address breaks ................................................................................................................ 117 5.4.1 features .............................................................................................................. 117 5.4.2 block diagram.................................................................................................... 117 5.4.3 operation............................................................................................................ 118 5.4.4 usage notes........................................................................................................ 118 5.5 interrupt operation........................................................................................................... 120 5.5.1 interrupt control modes and interrupt operation ................................................ 120 5.5.2 interrupt control mode 0 .................................................................................... 123 5.5.3 interrupt control mode 1 .................................................................................... 125 5.5.4 interrupt exception handling sequence .............................................................. 128 5.5.5 interrupt response times ................................................................................... 129 5.6 usage notes..................................................................................................................... 130 5.6.1 contention between interrupt generation and disabling ..................................... 130 5.6.2 instructions that disable interrupts...................................................................... 131 5.6.3 interrupts during execution of eepmov instruction .......................................... 131 5.7 dtc activation by interrupt ............................................................................................ 132 5.7.1 overview ............................................................................................................ 132 5.7.2 block diagram.................................................................................................... 132 5.7.3 operation............................................................................................................ 133
iv section 6 bus controller ................................................................................ 135 6.1 overview ......................................................................................................................... 135 6.1.1 features .............................................................................................................. 135 6.1.2 block diagram ................................................................................................... 136 6.1.3 pin configuration ............................................................................................... 137 6.1.4 register configuration........................................................................................ 137 6.2 register descriptions ....................................................................................................... 138 6.2.1 bus control register (bcr) ............................................................................... 138 6.2.2 wait state control register (wscr).................................................................. 140 6.3 overview of bus control ................................................................................................. 141 6.3.1 bus specifications .............................................................................................. 141 6.3.2 advanced mode.................................................................................................. 142 6.3.3 normal mode ..................................................................................................... 142 6.3.4 i/o select signal................................................................................................. 143 6.4 basic bus interface .......................................................................................................... 144 6.4.1 overview ............................................................................................................ 144 6.4.2 data size and data alignment............................................................................ 144 6.4.3 valid strobes ...................................................................................................... 146 6.4.4 basic timing ...................................................................................................... 147 6.4.5 wait control....................................................................................................... 155 6.5 burst rom interface........................................................................................................ 157 6.5.1 overview ............................................................................................................ 157 6.5.2 basic timing ...................................................................................................... 157 6.5.3 wait control....................................................................................................... 159 6.6 idle cycle ........................................................................................................................ 159 6.6.1 operation............................................................................................................ 159 6.6.2 pin states in idle cycle....................................................................................... 160 6.7 bus arbitration ................................................................................................................ 160 6.7.1 overview ............................................................................................................ 160 6.7.2 operation............................................................................................................ 160 6.7.3 bus transfer timing........................................................................................... 161 section 7 data transfer controller [h8s/2148 series] ................................... 163 7.1 overview ......................................................................................................................... 163 7.1.1 features .............................................................................................................. 163 7.1.2 block diagram ................................................................................................... 164 7.1.3 register configuration........................................................................................ 165 7.2 register descriptions ....................................................................................................... 166 7.2.1 dtc mode register a (mra)............................................................................ 166 7.2.2 dtc mode register b (mrb) ............................................................................ 168 7.2.3 dtc source address register (sar).................................................................. 169 7.2.4 dtc destination address register (dar).......................................................... 169
v 7.2.5 dtc transfer count register a (cra ) ........................................................ ......... . 169 7.2.6 dtc transfer count register b (crb ) .............................................................. . 170 7.2.7 dtc enable registers (dtcer ) ....................................................................... . 170 7.2.8 dtc vector register (dtvecr ) ...................................................................... . 172 7.2.9 module stop control register (mstpcr ) ......................................................... . 173 7.3 operatio n ........................................................................................................................ . 1 7 4 7.3.1 overvie w ........................................................................................................... . 1 7 4 7.3.2 activation source s ............................................................................................. . 176 7.3.3 dtc vector tabl e ............................................................................................. . 1 7 7 7.3.4 location of register information in address spac e ........................................... . 179 7.3.5 normal mode..................................................................................................... . 1 8 0 7.3.6 repeat mode...................................................................................................... . 1 8 1 7.3.7 block transfer mod e ......................................................................................... . 182 7.3.8 chain transfe r ................................................................................................... . 1 8 4 7.3.9 operation timin g .............................................................................................. . 1 8 5 7.3.10 number of dtc execution state s .................................................................... . 186 7.3.11 procedures for using the dt c ......................................................................... . 188 7.3.12 examples of use of the dt c ........................................................................... . 189 7.4 interrupt s ........................................................................................................................ . 1 9 0 7.5 usage note s .................................................................................................................... . 1 9 0 section 8 i/o port s .........................................................................................191 8.1 overvie w ........................................................................................................................ . 1 9 1 8.2 port 1 .............................................................................................................................. . 1 9 9 8.2.1 overvie w ........................................................................................................... . 1 9 9 8.2.2 register configuratio n ....................................................................................... . 200 8.2.3 pin functions in each mod e .............................................................................. . 202 8.2.4 mos input pull-up functio n ............................................................................. . 204 8.3 port 2 .............................................................................................................................. . 2 0 5 8.3.1 overvie w ........................................................................................................... . 2 0 5 8.3.2 register configuratio n ....................................................................................... . 206 8.3.3 pin functions in each mod e .............................................................................. . 208 8.3.4 mos input pull-up functio n ............................................................................. . 210 8.4 port 3 .............................................................................................................................. . 2 1 1 8.4.1 overvie w ........................................................................................................... . 2 1 1 8.4.2 register configuratio n ....................................................................................... . 212 8.4.3 pin functions in each mod e .............................................................................. . 214 8.4.4 mos input pull-up functio n ............................................................................. . 215 8.5 port 4 .............................................................................................................................. . 2 1 6 8.5.1 overvie w ........................................................................................................... . 2 1 6 8.5.2 register configuratio n ....................................................................................... . 217 8.5.3 pin function s ..................................................................................................... . 2 1 8
vi 8.6 port 5 ............................................................................................................................... 221 8.6.1 overview ............................................................................................................ 221 8.6.2 register configuration........................................................................................ 221 8.6.3 pin functions...................................................................................................... 223 8.7 port 6 ............................................................................................................................... 224 8.7.1 overview ............................................................................................................ 224 8.7.2 register configuration........................................................................................ 225 8.7.3 pin functions...................................................................................................... 228 8.7.4 mos input pull-up function .............................................................................. 230 8.8 port 7 ............................................................................................................................... 231 8.8.1 overview ............................................................................................................ 231 8.8.2 register configuration........................................................................................ 232 8.8.3 pin functions...................................................................................................... 232 8.9 port 8 ............................................................................................................................... 233 8.9.1 overview ............................................................................................................ 233 8.9.2 register configuration........................................................................................ 234 8.9.3 pin functions...................................................................................................... 235 8.10 port 9 ............................................................................................................................. 237 8.10.1 overview .......................................................................................................... 237 8.10.2 register configuration...................................................................................... 238 8.10.3 pin functions .................................................................................................... 240 8.11 port a ............................................................................................................................ 243 8.11.1 overview .......................................................................................................... 243 8.11.2 register configuration...................................................................................... 244 8.11.3 pin functions .................................................................................................... 245 8.11.4 mos input pull-up function ............................................................................ 249 8.12 port b ............................................................................................................................ 250 8.12.1 overview .......................................................................................................... 250 8.12.2 register configuration...................................................................................... 251 8.12.3 pin functions .................................................................................................... 253 8.12.4 mos input pull-up function ............................................................................ 256 section 9 8-bit pwm timers [h8s/2148 series] ........................................... 257 9.1 overview ......................................................................................................................... 257 9.1.1 features .............................................................................................................. 257 9.1.2 block diagram ................................................................................................... 258 9.1.3 pin configuration ............................................................................................... 259 9.1.4 register configuration........................................................................................ 259 9.2 register descriptions ....................................................................................................... 260 9.2.1 pwm register select (pwsl) ............................................................................ 260 9.2.2 pwm data registers (pwdr0 to pwdr15) ...................................................... 262 9.2.3 pwm data polarity registers a and b (pwdpra and pwdprb)..................... 263 9.2.4 pwm output enable registers a and b (pwoera and pwoerb) .................. 264
vii 9.2.5 peripheral clock select register (pcsr) ............................................................ 265 9.2.6 port 1 data direction register (p1ddr)............................................................. 266 9.2.7 port 2 data direction register (p2ddr)............................................................. 267 9.2.8 port 1 data register (p1dr) ............................................................................... 268 9.2.9 port 2 data register (p2dr) ............................................................................... 269 9.2.10 module stop control register (mstpcr) ........................................................ 270 9.3 operation ......................................................................................................................... 271 9.3.1 correspondence between pwm data register .................................................... 271 section 10 14-bit pwm d/a..........................................................................273 10.1 overview ....................................................................................................................... 273 10.1.1 features ............................................................................................................ 273 10.1.2 block diagram.................................................................................................. 274 10.1.3 pin configuration.............................................................................................. 275 10.1.4 register configuration...................................................................................... 275 10.2 register descriptions ..................................................................................................... 276 10.2.1 pwm d/a counter (dacnt)........................................................................... 276 10.2.2 d/a data registers a and b (dadra and dadrb)........................................ 277 10.2.3 pwm d/a control register (dacr) ................................................................ 279 10.2.4 module stop control register (mstpcr) ........................................................ 281 10.3 bus master interface ...................................................................................................... 282 10.4 operation ....................................................................................................................... 285 section 11 16-bit free-running timer...........................................................289 11.1 overview ....................................................................................................................... 289 11.1.1 features ............................................................................................................ 289 11.1.2 block diagram.................................................................................................. 290 11.1.3 input and output pins ....................................................................................... 291 11.1.4 register configuration...................................................................................... 292 11.2 register descriptions ..................................................................................................... 293 11.2.1 free-running counter (frc)............................................................................ 293 11.2.2 output compare registers a and b (ocra, ocrb) ........................................ 293 11.2.3 input capture registers a to d (icra to icrd)............................................... 294 11.2.4 output compare registers ar and af (ocrar, ocraf) .............................. 295 11.2.5 output compare register dm (ocrdm) ......................................................... 296 11.2.6 timer interrupt enable register (tier)............................................................ 297 11.2.7 timer control/status register (tcsr).............................................................. 299 11.2.8 timer control register (tcr) .......................................................................... 303 11.2.9 timer output compare control register (tocr)............................................. 305 11.2.10 module stop control register (mstpcr) ...................................................... 307 11.3 operation ....................................................................................................................... 308 11.3.1 frc increment timing ..................................................................................... 308 11.3.2 output compare output timing........................................................................ 310
viii 11.3.3 frc clear timing ............................................................................................ 311 11.3.4 input capture input timing .............................................................................. 311 11.3.5 timing of input capture flag (icf) setting ...................................................... 314 11.3.6 setting of output compare flags a and b (ocfa, ocfb)............................... 315 11.3.7 setting of frc overflow flag (ovf) ............................................................... 316 11.3.8 automatic addition of ocra and ocrar/ocraf ........................................ 317 11.3.9 icrd and ocrdm mask signal generation .................................................... 318 11.4 interrupts ....................................................................................................................... 319 11.5 sample application........................................................................................................ 320 11.6 usage notes................................................................................................................... 321 section 12 8-bit timers ................................................................................. 327 12.1 overview ....................................................................................................................... 327 12.1.1 features ............................................................................................................ 327 12.1.2 block diagram.................................................................................................. 328 12.1.3 pin configuration.............................................................................................. 329 12.1.4 register configuration...................................................................................... 330 12.2 register descriptions ..................................................................................................... 331 12.2.1 timer counter (tcnt)..................................................................................... 331 12.2.2 time constant register a (tcora) ................................................................ 332 12.2.3 time constant register b (tcorb)................................................................. 333 12.2.4 timer control register (tcr) .......................................................................... 334 12.2.5 timer control/status register (tcsr).............................................................. 338 12.2.6 serial/timer control register (stcr) .............................................................. 342 12.2.7 system control register (syscr).................................................................... 343 12.2.8 timer connection register s (tconrs).......................................................... 344 12.2.9 input capture register (ticr) [tmrx additional function] ........................... 345 12.2.10 time constant register c (tcorc) [tmrx additional function] ................ 345 12.2.11 input capture registers r and f (ticrr, ticrf).......................................... 345 12.2.12 timer input select register (tisr) [tmry additional function] .................. 346 12.2.13 module stop control register (mstpcr) ...................................................... 347 12.3 operation ....................................................................................................................... 348 12.3.1 tcnt incrementation timing .......................................................................... 348 12.3.2 compare-match timing.................................................................................... 350 12.3.3 tcnt external reset timing ........................................................................... 351 12.3.4 timing of overflow flag (ovf) setting ........................................................... 352 12.3.5 operation with cascaded connection................................................................ 353 12.4 interrupt sources............................................................................................................ 354 12.5 8-bit timer application example .................................................................................. 355 12.6 usage notes................................................................................................................... 356 12.6.1 contention between tcnt write and clear...................................................... 356 12.6.2 contention between tcnt write and increment .............................................. 357 12.6.3 contention between tcor write and compare-match..................................... 358
ix 12.6.4 contention between compare-matches a and b ............................................... 359 12.6.5 switching of internal clocks and tcnt operation ........................................... 359 section 13 timer connection [h8s/2148 series]............................................363 13.1 overview ....................................................................................................................... 363 13.1.1 features ............................................................................................................ 363 13.1.2 block diagram.................................................................................................. 364 13.1.3 input and output pins ....................................................................................... 365 13.1.4 register configuration...................................................................................... 366 13.2 register descriptions ..................................................................................................... 367 13.2.1 timer connection register i (tconri) ........................................................... 367 13.2.2 timer connection register o (tconro) ........................................................ 370 13.2.3 timer connection register s (tconrs).......................................................... 372 13.2.4 edge sense register (sedgr).......................................................................... 374 13.2.5 module stop control register (mstpcr) ........................................................ 377 13.3 operation ....................................................................................................................... 378 13.3.1 pwm decoding (pdc signal generation) ........................................................ 378 13.3.2 clamp waveform generation (cl1/cl2/cl3 signal generation) .................... 380 13.3.3 measurement of 8-bit timer divided waveform period ................................... 382 13.3.4 ihi signal and 2fh modification....................................................................... 383 13.3.5 ivi signal fall modification and ihi synchronization ...................................... 385 13.3.6 internal synchronization signal generation ...................................................... 386 13.3.7 hsynco output .............................................................................................. 389 13.3.8 vsynco output .............................................................................................. 390 13.3.9 cblank output .............................................................................................. 391 section 14 watchdog timer (wdt)...............................................................393 14.1 overview ....................................................................................................................... 393 14.1.1 features ............................................................................................................ 393 14.1.2 block diagram.................................................................................................. 394 14.1.3 pin configuration.............................................................................................. 396 14.1.4 register configuration...................................................................................... 396 14.2 register descriptions ..................................................................................................... 397 14.2.1 timer counter (tcnt)..................................................................................... 397 14.2.2 timer control/status register (tcsr).............................................................. 398 14.2.3 system control register (syscr).................................................................... 402 14.2.4 notes on register access.................................................................................. 403 14.3 operation ....................................................................................................................... 403 14.3.1 watchdog timer operation............................................................................... 403 14.3.2 interval timer operation .................................................................................. 405 14.3.3 timing of setting of overflow flag (ovf) ....................................................... 406 14.3.4 reso signal output timing............................................................................. 407 14.4 interrupts........................................................................................................................ 407
x 14.5 usage note s ................................................................................................................ ........ . 4 0 8 14.5.1 contention between timer counter (tcnt) write and incremen t ................... . 408 14.5.2 changing value of cks2 to cks 0 .................................................................. . 408 14.5.3 switching between watchdog timer mode and interval timer mod e .............. . 408 14.5.4 system reset by reso signa l ......................................................................... . 409 14.5.5 counter value in transitions between.............................................................. . 409 section 15 serial communication interface (sci, irda ) ............................... . 411 15.1 overvie w ...................................................................................................................... . 4 1 1 15.1.1 feature s ........................................................................................................... . 4 1 1 15.1.2 block diagram................................................................................................. . 4 1 3 15.1.3 pin configuration............................................................................................. . 414 15.1.4 register configuratio n ..................................................................................... . 415 15.2 register description s .................................................................................................... . 416 15.2.1 receive shift register (rsr ) ........................................................................... . 416 15.2.2 receive data register (rdr ) .......................................................................... . 416 15.2.3 transmit shift register (tsr ) ......................................................................... . 417 15.2.4 transmit data register (tdr ) ......................................................................... . 417 15.2.5 serial mode register (smr ) ............................................................................ . 418 15.2.6 serial control register (scr ) .......................................................................... . 422 15.2.7 serial status register (ssr ) ............................................................................. . 426 15.2.8 bit rate register (brr ) .................................................................................. . 430 15.2.9 serial interface mode register (scmr ) ........................................................... . 438 15.2.10 module stop control register (mstpcr ) ..................................................... . 440 15.2.11 keyboard comparator control register (kbcomp ) ...................................... . 442 15.3 operatio n ...................................................................................................................... . 4 4 3 15.3.1 overvie w ......................................................................................................... . 4 4 3 15.3.2 operation in asynchronous mod e .................................................................... . 445 15.3.3 multiprocessor communication function......................................................... . 456 15.3.4 operation in synchronous mod e ...................................................................... . 464 15.3.5 irda operatio n ................................................................................................ . 472 15.4 sci interrupts................................................................................................................ . 4 7 5 15.5 usage note s .................................................................................................................. . 4 7 6 section 16 i 2 c bus interface [h8s/2148 series option ] ................................ . 481 16.1 overvie w ...................................................................................................................... . 4 8 1 16.1.1 feature s ........................................................................................................... . 4 8 1 16.1.2 block diagram................................................................................................. . 4 8 3 16.1.3 input/output pin s ............................................................................................. . 484 16.1.4 register configuratio n ..................................................................................... . 485 16.2 register description s .................................................................................................... . 486 16.2.1 i 2 c bus data register (icdr ) .......................................................................... . 486 16.2.2 slave address register (sar ) ......................................................................... . 489
xi 16.2.3 second slave address register (sarx)............................................................ 491 16.2.4 i 2 c bus mode register (icmr)......................................................................... 492 16.2.5 i 2 c bus control register (iccr)....................................................................... 496 16.2.6 i 2 c bus status register (icsr) ......................................................................... 504 16.2.7 serial/timer control register (stcr) .............................................................. 509 16.2.8 ddc switch register (ddcswr) .................................................................... 511 16.2.9 module stop control register (mstpcr) ........................................................ 514 16.3 operation ....................................................................................................................... 515 16.3.1 i 2 c bus data format ......................................................................................... 515 16.3.2 master transmit operation ............................................................................... 517 16.3.3 master receive operation................................................................................. 519 16.3.4 slave receive operation................................................................................... 521 16.3.5 slave transmit operation ................................................................................. 523 16.3.6 iric setting timing and scl control .............................................................. 525 16.3.7 automatic switching from formatless mode to i 2 c bus format ....................... 526 16.3.8 operation using the dtc ................................................................................. 527 16.3.9 noise canceler.................................................................................................. 528 16.3.10 sample flowcharts.......................................................................................... 529 16.3.11 initialization of internal state.......................................................................... 533 16.4 usage notes ................................................................................................................... 534 section 17 keyboard buffer controller [h8s/2148 series].............................539 17.1 overview ....................................................................................................................... 539 17.1.1 features ............................................................................................................ 539 17.1.2 block diagram.................................................................................................. 540 17.1.3 input/output pins.............................................................................................. 541 17.1.4 register configuration...................................................................................... 541 17.2 register descriptions ..................................................................................................... 542 17.2.1 keyboard control register h (kbcrh) ........................................................... 542 17.2.2 keyboard control register l (kbcrl) ............................................................ 545 17.2.3 keyboard data buffer register (kbbr) ........................................................... 547 17.3 operation ....................................................................................................................... 548 17.3.1 receive operation ............................................................................................ 548 17.3.2 transmit operation ........................................................................................... 550 17.3.3 receive abort................................................................................................... 552 17.3.4 kclki and kdi read timing .......................................................................... 555 17.3.5 kclko and kdo write timing ...................................................................... 555 17.3.6 kbf setting timing and kclk control ........................................................... 556 17.3.7 receive timing ................................................................................................ 557 17.3.8 kclk fall interrupt operation ......................................................................... 558 17.3.9 usage note ....................................................................................................... 559
xii section 18 host interface [h8s/2148 series] ................................................. 561 18.1 overview ....................................................................................................................... 561 18.1.1 features ............................................................................................................ 561 18.1.2 block diagram.................................................................................................. 562 18.1.3 input and output pins ....................................................................................... 563 18.1.4 register configuration...................................................................................... 564 18.2 register descriptions ..................................................................................................... 565 18.2.1 system control register (syscr).................................................................... 565 18.2.2 system control register 2 (syscr2) ............................................................... 566 18.2.3 host interface control register (hicr) ............................................................ 568 18.2.4 input data register 1 (idr1) ............................................................................ 570 18.2.5 output data register 1 (odr) .......................................................................... 570 18.2.6 status register (str) ....................................................................................... 571 18.2.7 module stop control register (mstpcr) ........................................................ 573 18.3 operation ....................................................................................................................... 574 18.3.1 host interface activation .................................................................................. 574 18.3.2 control states ................................................................................................... 575 18.3.3 a20 gate .......................................................................................................... 576 18.3.4 host interface pin shutdown function .............................................................. 578 18.4 interrupts ....................................................................................................................... 580 18.4.1 ibf1, ibf2, ibf3, ibf4.................................................................................... 580 18.4.2 hirq11, hirq1, hirq12, hirq3, and hirq4............................................... 580 18.5 usage note .................................................................................................................... 582 section 19 d/a converter.............................................................................. 583 19.1 overview ....................................................................................................................... 583 19.1.1 features ............................................................................................................ 583 19.1.2 block diagram.................................................................................................. 584 19.1.3 input and output pins ....................................................................................... 585 19.1.4 register configuration...................................................................................... 585 19.2 register descriptions ..................................................................................................... 586 19.2.1 d/a data registers 0 and 1 (dadr0, dadr1)................................................ 586 19.2.2 d/a control register (dacr) .......................................................................... 586 19.2.3 module stop control register (mstpcr) ........................................................ 588 19.3 operation ....................................................................................................................... 589 section 20 a/d converter.............................................................................. 591 20.1 overview ....................................................................................................................... 591 20.1.1 features ............................................................................................................ 591 20.1.2 block diagram.................................................................................................. 592 20.1.3 pin configuration.............................................................................................. 593 20.1.4 register configuration...................................................................................... 594
xiii 20.2 register descriptions ..................................................................................................... 595 20.2.1 a/d data registers a to d (addra to addrd) ............................................ 595 20.2.2 a/d control/status register (adcsr).............................................................. 596 20.2.3 a/d control register (adcr) .......................................................................... 599 20.2.4 keyboard comparator control register (kbcomp)......................................... 600 20.2.5 module stop control register (mstpcr) ........................................................ 601 20.3 interface to bus master .................................................................................................. 602 20.4 operation ....................................................................................................................... 603 20.4.1 single mode (scan = 0).................................................................................. 603 20.4.2 scan mode (scan = 1) .................................................................................... 605 20.4.3 input sampling and a/d conversion time........................................................ 607 20.4.4 external trigger input timing .......................................................................... 608 20.5 interrupts........................................................................................................................ 608 20.6 usage notes ................................................................................................................... 609 section 21 ram.............................................................................................615 21.1 overview ....................................................................................................................... 615 21.1.1 block diagram.................................................................................................. 615 21.1.2 register configuration...................................................................................... 616 21.2 system control register (syscr) ................................................................................. 616 21.3 operation ....................................................................................................................... 617 21.3.1 expanded mode (modes 1, 2, and 3 (expe = 1)).............................................. 617 21.3.2 single-chip mode (modes 2 and 3 (expe = 0)) ............................................... 617 section 22 rom.............................................................................................619 22.1 overview ....................................................................................................................... 619 22.1.1 block diagram.................................................................................................. 619 22.1.2 register configuration...................................................................................... 620 22.2 register descriptions ..................................................................................................... 620 22.2.1 mode control register (mdcr) ....................................................................... 620 22.3 operation ....................................................................................................................... 621 22.4 overview of flash memory............................................................................................ 622 22.4.1 features ............................................................................................................ 622 22.4.2 block diagram.................................................................................................. 623 22.4.3 flash memory operating modes ....................................................................... 624 22.4.4 pin configuration.............................................................................................. 628 22.4.5 register configuration...................................................................................... 629 22.5 register descriptions ..................................................................................................... 630 22.5.1 flash memory control register 1 (flmcr1) ................................................... 630 22.5.2 flash memory control register 2 (flmcr2) ................................................... 632 22.5.3 erase block registers 1 and 2 (ebr1, ebr2)................................................... 634 22.5.4 serial/timer control register (stcr) .............................................................. 635
xiv 22.6 on-board programming modes...................................................................................... 636 22.6.1 boot mode........................................................................................................ 637 22.6.2 user program mode.......................................................................................... 642 22.7 programming/erasing flash memory ............................................................................. 643 22.7.1 program mode .................................................................................................. 643 22.7.2 program-verify mode....................................................................................... 644 22.7.3 erase mode....................................................................................................... 646 22.7.4 erase-verify mode ........................................................................................... 646 22.8 flash memory protection ............................................................................................... 648 22.8.1 hardware protection ......................................................................................... 648 22.8.2 software protection........................................................................................... 649 22.8.3 error protection ................................................................................................ 650 22.9 interrupt handling when programming/erasing flash memory ...................................... 652 22.10 flash memory writer mode ......................................................................................... 653 22.10.1 writer mode setting ....................................................................................... 653 22.10.2 socket adapters and memory map ................................................................. 653 22.10.3 writer mode operation................................................................................... 654 22.10.4 memory read mode ....................................................................................... 655 22.10.5 auto-program mode ....................................................................................... 658 22.10.6 auto-erase mode............................................................................................ 660 22.10.7 status read mode ........................................................................................... 661 22.10.8 status polling.................................................................................................. 663 22.10.9 writer mode transition time ......................................................................... 663 22.10.10 notes on memory programming................................................................... 664 22.11 flash memory programming and erasing precautions.................................................. 664 section 23 clock pulse generator .................................................................. 667 23.1 overview ....................................................................................................................... 667 23.1.1 block diagram.................................................................................................. 667 23.1.2 register configuration...................................................................................... 667 23.2 register descriptions ..................................................................................................... 668 23.2.1 standby control register (sbycr) .................................................................. 668 23.2.2 low-power control register (lpwrcr) ......................................................... 669 23.3 oscillator ....................................................................................................................... 670 23.3.1 connecting a crystal resonator ........................................................................ 670 23.3.2 external clock input......................................................................................... 672 23.4 duty adjustment circuit ................................................................................................ 675 23.5 medium-speed clock divider........................................................................................ 675 23.6 bus master clock selection circuit................................................................................ 675 23.7 subclock input circuit ................................................................................................... 675 23.8 subclock waveform shaping circuit ............................................................................. 676
xv section 24 power-down state ........................................................................677 24.1 overview ....................................................................................................................... 677 24.1.1 register configuration...................................................................................... 680 24.2 register descriptions ..................................................................................................... 681 24.2.1 standby control register (sbycr) .................................................................. 681 24.2.2 low-power control register (lpwrcr) ......................................................... 683 24.2.3 timer control/status register (tcsr).............................................................. 685 24.2.4 module stop control register (mstpcr) ........................................................ 686 24.3 medium-speed mode..................................................................................................... 687 24.4 sleep mode .................................................................................................................... 688 24.4.1 sleep mode....................................................................................................... 688 24.4.2 clearing sleep mode......................................................................................... 688 24.5 module stop mode......................................................................................................... 688 24.5.1 module stop mode ........................................................................................... 688 24.5.2 usage note ....................................................................................................... 689 24.6 software standby mode ................................................................................................. 690 24.6.1 software standby mode .................................................................................... 690 24.6.2 clearing software standby mode...................................................................... 690 24.6.3 setting oscillation settling time after clearing software standby mode.......... 691 24.6.4 software standby mode application example .................................................. 692 24.6.5 usage note ....................................................................................................... 693 24.7 hardware standby mode................................................................................................ 693 24.7.1 hardware standby mode................................................................................... 693 24.7.2 hardware standby mode timing ...................................................................... 694 24.8 watch mode .................................................................................................................. 694 24.8.1 watch mode ..................................................................................................... 694 24.8.2 clearing watch mode ....................................................................................... 695 24.9 subsleep mode............................................................................................................... 695 24.9.1 subsleep mode.................................................................................................. 695 24.9.2 clearing subsleep mode ................................................................................... 696 24.10 subactive mode ........................................................................................................... 696 24.10.1 subactive mode .............................................................................................. 696 24.10.2 clearing subactive mode ................................................................................ 697 24.11 direct transition .......................................................................................................... 697 24.11.1 overview of direct transition......................................................................... 697 section 25 electrical characteristics...............................................................699 25.1 absolute maximum ratings........................................................................................... 699 25.2 dc characteristics ......................................................................................................... 700 25.3 ac characteristics ......................................................................................................... 717 25.3.1 clock timing.................................................................................................... 718 25.3.2 control signal timing ...................................................................................... 720
xvi 25.3.3 bus timing....................................................................................................... 722 25.3.4 timing of on-chip supporting modules........................................................... 730 25.4 a/d conversion characteristics ..................................................................................... 742 25.5 d/a conversion characteristics ..................................................................................... 744 25.6 flash memory characteristics ........................................................................................ 745 25.7 usage note .................................................................................................................... 747 appendix a instruction set............................................................................ 749 a.1 instruction....................................................................................................................... 749 a.2 instruction codes ............................................................................................................ 767 a.3 operation code map ....................................................................................................... 781 a.4 number of states required for execution ....................................................................... 785 a.5 bus states during instruction execution ......................................................................... 798 appendix b internal i/o registers ................................................................. 815 b.1 addresses ........................................................................................................................ 815 b.2 register selection conditions.......................................................................................... 822 b.3 functions......................................................................................................................... 829 appendix c i/o port block diagrams............................................................ 911 c.1 port 1 block diagram...................................................................................................... 911 c.2 port 2 block diagrams .................................................................................................... 912 c.3 port 3 block diagram...................................................................................................... 915 c.4 port 4 block diagrams .................................................................................................... 916 c.5 port 5 block diagrams .................................................................................................... 923 c.6 port 6 block diagrams .................................................................................................... 926 c.7 port 7 block diagrams .................................................................................................... 931 c.8 port 8 block diagrams .................................................................................................... 932 c.9 port 9 block diagrams .................................................................................................... 938 c.10 port a block diagrams.................................................................................................. 943 c.11 port b block diagram ................................................................................................... 946 appendix d pin states ................................................................................... 949 d.1 port states in each processing state................................................................................ 949 appendix e timing of transition to and recovery .................. from hardware standby mode...................................................... 951 e.1 timing of transition to hardware standby mode............................................................ 951 e.2 timing of recovery from hardware standby mode......................................................... 951 appendix f product code lineup .................................................................. 953 appendix g package dimensions .................................................................. 955
1 preface the h8s/2148 series and h8s/2144 series comprise high-performance microcomputers with a 32-bit h8s/2000 cpu core, and a set of on-chip supporting functions required for system configuration. the h8s/2000 cpu can execute basic instructions in one state, and is provided with sixteen internal 16-bit general registers with a 32-bit configuration, and a concise and optimized instruction set. the cpu can handle a 16-mbyte linear address space (architecturally 4 gbytes). programs based on the high-level language c can also be run efficiently. single-power-supply flash memory (f-ztat?*) and mask rom versions are available, providing a quick and flexible response to conditions from ramp-up through full-scale volume production, even for applications with frequently changing specifications. on-chip peripheral functions include a 16-bit free-running timer (frt), 8-bit timer (tmr), watchdog timer (wdt), two pwm timers (pwm and pwmx), a serial communication interface (sci, irda), ps/2-compatible keyboard buffer controller, host interface (hif), d/a converter (dac), a/d converter (adc), and i/o ports. an i 2 c bus interface (iic) can also be incorporated as an option. an on-chip data transfer controller (dtc) is also provided, enabling high-speed data transfer without cpu intervention. the h8s/2148 series has all the above on-chip supporting functions, and can also be provided with an iic module as an option. the h8s/2144 series comprises reduced-function versions, with fewer tmr channels, and no pwm, keyboard buffer controller, hif, iic, or dtc modules. use of the h8s/2148 or h8s/2144 series enables compact, high-performance systems to be implemented easily. the comprehensive pc-related interface functions and 16 8 matrix key- scan functions are ideal for applications such as notebook pc keyboard control and intelligent battery and power supply control, while the various timer functions and their interconnectability (timer connection), plus the interlinked operation of the i 2 c bus interface and data transfer controller (dtc), in particular, make these devices ideal for use in pc monitors. in addition, the combination of f-ztat?* and reduced-function versions is ideal for applications such as cd- rom drive units in which on-chip program memory is essential to meet performance requirements, product start-up times are short, and program modifications may be necessary after end-product assembly. this manual describes the hardware of the h8s/2148 series and h8s/2144 series. refer to the h8s/2600 series and h8s/2000 series programming manual for a detailed description of the instruction set. note: * f-ztat? (flexible-ztat) is a trademark of hitachi, ltd.
2 on-chip supporting modules series h8s/2148 series h8s/2144 series product names h8s/2148, 2147 h8s/2144, 2143, 2142 bus controller (bsc) available (16 bits) available (16 bits) data transfer controller (dtc) available 8-bit pwm timer (pwm) 16 14-bit pwm timer (pwmx) 2 2 16-bit free-running timer (frt) 1 1 8-bit timer (tmr) 4 3 timer connection available watchdog timer (wdt) 2 2 serial communication interface (sci) 3 3 i 2 c bus interface (iic) 2 (option) keyboard buffer controller (ps/2 compatible) 3 host interface (hif) 4 d/a converter 2 2 a/d converter 8 (analog inputs) 8 (analog inputs) 16 (expansion a/d inputs) 16 (expansion a/d inputs)
3 section 1 overview 1.1 overview the h8s/2148 series and h8s/2144 series comprise microcomputers (mcus) built around the h8s/2000 cpu, employing hitachis proprietary architecture, and equipped with supporting modules on-chip. the h8s/2000 cpu has an internal 32-bit architecture, is provided with sixteen 16-bit general registers and a concise, optimized instruction set designed for high-speed operation, and can address a 16-mbyte linear address space. the instruction set is upward-compatible with h8/300 and h8/300h cpu instructions at the object-code level, facilitating migration from the h8/300, h8/300l, or h8/300h series. on-chip supporting modules required for system configuration include a data transfer controller (dtc) bus master, rom and ram memory, a16-bit free-running timer module (frt), 8-bit timer module (tmr), watchdog timer module (wdt), two pwm timers (pwm and pwmx), serial communication interface (sci), ps/2-compatible keyboard buffer controller, host interface (hif), d/a converter (dac), a/d converter (adc), and i/o ports. an i 2 c bus interface (iic) can also be incorporated as an option. the on-chip rom is either flash memory (f-ztat?*) or mask rom, with a capacity of 128, 96, or 64 kbytes. rom is connected to the cpu via a 16-bit data bus, enabling both byte and word data to be accessed in one state. instruction fetching has been speeded up, and processing speed increased. three operating modes, modes 1 to 3, are provided, and there is a choice of address space and single-chip mode or externally expanded modes. the features of the h8s/2148 series and h8s/2144 series are shown in table 1.1. note: * f-ztat? is a trademark of hitachi, ltd.
4 table 1.1 overview item specifications cpu general-register architecture ? sixteen 16-bit general registers (also usable as sixteen 8-bit registers or eight 32-bit registers) high-speed operation suitable for real-time control ? maximum operating frequency: 20 mhz/5 v, 10 mhz/3 v ? high-speed arithmetic operations 8/16/32-bit register-register add/subtract: 50 ns (20 mhz operation) 16 16-bit register-register multiply: 1000 ns (20 mhz operation) 32 16-bit register-register divide: 1000 ns (20 mhz operation) instruction set suitable for high-speed operation ? sixty-five basic instructions ? 8/16/32-bit transfer/arithmetic and logic instructions ? unsigned/signed multiply and divide instructions ? powerful bit-manipulation instructions two cpu operating modes ? normal mode: 64-kbyte address space ? advanced mode: 16-mbyte address space operating modes three mcu operating modes external data bus mode cpu operating mode description on-chip rom initial value maximum value 1 normal expanded mode with on-chip rom disabled disabled 8 bits 16 bits 2 advanced single-chip mode enabled none none expanded mode with on-chip rom enabled enabled 8 bits 16 bits 3 normal single-chip mode enabled none none expanded mode with on-chip rom enabled enabled 8 bits 16 bits bus controller 2-state or 3-state access space can be designated for external expansion areas number of program wait states can be set for external expansion areas
5 table 1.1 overview (cont) item specifications data transfer controller (dtc) (h8s/2148 series) can be activated by internal interrupt or software multiple transfers or multiple types of transfer possible for one activation source transfer possible in repeat mode, block transfer mode, etc. request can be sent to cpu for interrupt that activated dtc 16-bit free-running timer module (frt: 1 channel) one 16-bit free-running counter (also usable for external event counting) two output compare outputs four input capture inputs (with buffer operation capability) 8-bit timer module (2 channels: tmr0, tmr1) each channel has: one 8-bit up-counter (also usable for external event counting) two timer constant registers the two channels can be connected timer connection and 8-bit timer module (tmr) (2 channels: tmrx, tmry) (timer connection and tmrx provided in h8s/2148 series) input/output and frt, tmr1, tmrx, tmry can be interconnected measurement of input signal or frequency-divided waveform pulse width and cycle (frt, tmr1) output of waveform obtained by modification of input signal edge (frt, tmr1) determination of input signal duty cycle (tmrx) output of waveform synchronized with input signal (frt, tmrx, tmry) automatic generation of cyclical waveform (frt, tmry) watchdog timer module (wdt: 2 channels) watchdog timer or interval timer function selectable subclock operation capability (channel 1 only) 8-bit pwm timer (pwm) (h8s/2148 series) up to 16 outputs pulse duty cycle settable from 0 to 100% resolution: 1/256 1.25 mhz maximum carrier frequency (20 mhz operation) 14-bit pwm timer (pwmx) up to 2 outputs resolution: 1/16384 312.5 khz maximum carrier frequency (20 mhz operation) serial communication interface (sci: 2 channels, sci0 and sci1) asynchronous mode or synchronous mode selectable multiprocessor communication function sci with irda: 1 channel (sci2) asynchronous mode or synchronous mode selectable multiprocessor communication function compatible with irda specification version 1.0 txd and rxd encoding/decoding in irda format
6 table 1.1 overview (cont) item specifications keyboard buffer controller (ps2: 3 channels) (h8s/2148 series) compatible with ps/2 interface direct manipulation of transmission output by software receive data input to 8-bit shift register data receive completed interrupt, parity error detection, stop bit monitoring host interface (hif) (h8s/2148 series) 8-bit high-impedance (isa) port five host interrupt requests (hirq11, hirq1, hirq12, hirq3, hirq4) normal and fast a20 gate output four register sets (each comprising two data registers and two status registers) keyboard controller matrix keyboard control using keyboard scan with wakeup interrupt and sense port configuration a/d converter resolution: 10 bits input: ? 8 channels (dedicated analog pins) ? 16 channels (same pins as keyboard sense port) high-speed conversion: 6.7 s minimum conversion time (20 mhz operation) single or scan mode selectable sample-and-hold function a/d conversion can be activated by external trigger or timer trigger d/a converter resolution: 8 bits output: 2 channels i/o ports 74 input/output pins (including 24 with led drive capability) 8 input-only pins vccb (separate power supply) drive pins among i/o pins (h8s/2148 seris only) memory flash memory or mask rom high-speed static ram product name rom ram h8s/2144, h8s/2148 128 kbytes 4 kbytes h8s/2143 96 kbytes 4 kbytes h8s/2142, h8s/2147 64 kbytes 2 kbytes
7 table 1.1 overview (cont) item specifications interrupt controller nine external interrupt pins (nmi, ,54 to ,54 ) 44 internal interrupt sources three priority levels settable power-down state medium-speed mode sleep mode module stop mode software standby mode hardware standby mode subclock operation clock pulse generator built-in duty correction circuit packages 100-pin plastic qfp (fp-100b) 100-pin plastic tqfp (tfp-100b) i 2 c bus interface (iic: 2 channels) (option in h8s/2148 series) conforms to philips i 2 c bus interface standard single master mode/slave mode arbitration lost condition can be identified supports two slave addresses product lineup product code (preliminary) series mask rom versions f-ztat? versions rom/ram (bytes) packages h8s/2148 hd6432148 hd64f2148 128 k/4 k fp-100b, hd6432148w * tfp-100b hd6432147 64 k/2 k hd6432147w * h8s/2144 hd6432144 hd64f2144 128 k/4 k hd6432143 96 k/4 k hd6432142 hd64f2142r 64 k/2 k note: * w indicates the i 2 c bus option.
8 1.2 internal block diagram an internal block diagram of the h8s/2148 series is shown in figure 1.1 (a), and an internal block diagram of the h8s/2144 series in figure 1.1 (b). h8s/2000 cpu dtc wdt0, wdt1 rom ram p17/a7/pw7 p16/a6/pw6 p15/a5/pw5 p14/a4/pw4 p13/a3/pw3 p12/a2/pw2 p11/a1/pw1 p10/a0/pw0 p27/a15/pw15/cblank p26/a14/pw14 p25/a13/pw13 p24/a12/pw12 p23/a11/pw11 p22/a10/pw10 p21/a9/pw9 p20/a8/pw8 pa7/a23/ kin15 /cin15/ps2cd pa6/a22/ kin14 /cin14/ps2cc pa5/a21/ kin13 /cin13/ps2bd pa4/a20/ kin12 /cin12/ps2bc pa3/a19/ kin11 /cin11/ps2ad pa2/a18/ kin10 /cin10/ps2ac pa1/a17/ kin9 /cin9 pa0/a16/ kin8 /cin8 p37/d15/hdb7 p36/d14/hdb6 p35/d13/hdb5 p34/d12/hdb4 p33/d11/hdb3 p32/d10/hdb2 p31/d9/hdb1 p30/d8/hdb0 pb7/d7 pb6/d6 pb5/d5 pb4/d4 pb3/d3/ cs4 pb2/d2/ cs3 pb1/d1/hirq4 pb0/d0/hirq3 p97/ wait /sda0 p96/?excl p95/ as / ios / cs1 p94/ hwr / iow p93/ rd / ior p92/ irq0 p91/ irq1 p90/ lwr / irq2 / adtrg / ecs2 p67/tmox/cin7/ kin7 / irq7 p66/ftob/cin6/ kin6 / irq6 p65/ftid/cin5/ kin5 p64/ftic/cin4/ kin4 /clampo p63/ftib/cin3/ kin3 /vfbacki p62/ftia/cin2/ kin2 /vsynci/tmiy p61/ftoa/cin1/ kin1 /vsynco p60/ftci/cin0/ kin0 /hfbacki/tmix p47/pwx1 p46/pwx0 p45/tmri1/hirq12/csynci p44/tmo1/hirq1/hsynco p43/tmci1/hirq11/hsynci p42/tmri0/sck2/sda1 p41/tmo0/rxd2/irrxd p40/tmci0/txd2/irtxd p52/sck0/scl0 p51/rxd0 p50/txd0 p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 p86/ irq5 /sck1/scl1 p85/ irq4 /rxd1 p84/ irq3 /txd1 p83 p82/hifsd p81/ cs2 /ga20 p80/ha0 avref avcc avss res xtal extal vccb md1 md0 nmi stby reso vcc1 vcc2 vss vss vss vss vss port 9 port 6 port 4 port 5 port a port 2 port 1 port 3 port b clock pulse generator interrupt controller 16-bit frt 8-bit timer 4ch (tmr0, tmr1, tmrx, tmry) timer connection sci 3ch (irda 1ch) iic 2ch (option) port 8 port 7 internal data bus internal address bus bus controller keyboard buffer controller 3ch 8-bit pwm 14-bit pwm host interface 10-bit a/d 8-bit d/a figure 1.1 (a) internal block diagram of h8s/2148 series
9 h8s/2000 cpu wdt0, wdt1 rom ram p17/a7 p16/a6 p15/a5 p14/a4 p13/a3 p12/a2 p11/a1 p10/a0 p27/a15 p26/a14 p25/a13 p24/a12 p23/a11 p22/a10 p21/a9 p20/a8 pa7/a23/ kin15 /cin15 pa6/a22/ kin14 /cin14 pa5/a21/ kin13 /cin13 pa4/a20/ kin12 /cin12 pa3/a19/ kin11 /cin11 pa2/a18/ kin10 /cin10 pa1/a17/ kin9 /cin9 pa0/a16/ kin8 /cin8 p37/d15 p36/d14 p35/d13 p34/d12 p33/d11 p32/d10 p31/d9 p30/d8 pb7/d7 pb6/d6 pb5/d5 pb4/d4 pb3/d3 pb2/d2 pb1/d1 pb0/d0 p97/ wait p96/?excl p95/ as / ios p94/ hwr p93/ rd p92/ irq0 p91/ irq1 p90/ lwr / irq2 / adtrg p67/cin7/ kin7 / irq7 p66/ftob/cin6/ kin6 / irq6 p65/ftid/cin5/ kin5 p64/ftic/cin4/ kin4 p63/ftib/cin3/ kin3 p62/ftia/cin2/ kin2 /tmiy p61/ftoa/cin1/ kin1 p60/ftci/cin0/ kin0 p47/pwx1 p46/pwx0 p45/tmri1 p44/tmo1 p43/tmci1 p42/tmri0/sck2 p41/tmo0/rxd2/irrxd p40/tmci0/txd2/irtxd p52/sck0 p51/rxd0 p50/txd0 p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 p86/ irq5 /sck1 p85/ irq4 /rxd1 p84/ irq3 /txd1 p83 p82 p81 p80 avref avcc avss res xtal extal md1 md0 nmi stby reso vcc1 vcc2 vss vss vss vss vss port a clock pulse generator interrupt controller 16-bit frt 8-bit timer 3ch (tmr0, tmr1, tmry) sci 3ch (irda 1ch) internal data bus internal address bus bus controller 14-bit pwm 10-bit a/d 8-bit d/a port 9 port 6 port 4 port 5 port 2 port 1 port 3 port b port 8 port 7 figure 1.1 (b) internal block diagram of h8s/2144 series
10 1.3 pin arrangement and functions 1.3.1 pin arrangement the pin arrangement of the h8s/2148 series is shown in figure 1.2 (a), and the pin arrangement of the h8s/2144 series in figure 1.2 (b). fp-100b tfp-100b (top view) 12345678910111213141516171819202122232425 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 res xtal extal vccb md1 md0 nmi stby vcc ps2cd/ kin15 /cin15/a23/pa7 ps2cc/ kin14 /cin14/a22/pa6 scl0/sck0/p52 rxd0/p51 txd0/p50 vss sda0/ wait /p97 excl/?p96 cs1 / ios / as /p95 iow / hwr /p94 ps2bd/ kin13 /cin13/a21/pa5 ps2bc/ kin12 /cin12/a20/pa4 ior / rd /p93 irq0 /p92 irq1 /p91 adtrg / irq2 / ecs2 / lwr /p90 p14/a4/pw4 p15/a5/pw5 p16/a6/pw6 p17/a7/pw7 vss vss pb4/d4 pb5/d5 p20/a8/pw8 p21/a9/pw9 p22/a10/pw10 p23/a11/pw11 p24/a12/pw12 p25/a13/pw13 p26/a14/pw14 p27/a15/pw15/cblank vcc pb6/d6 pb7/d7 p47/pwx1 p46/pwx0 p45/tmri1/hirq12/csynci p44/tmo1/hirq1/hsynco p43/tmci1/hirq11/hsynci p42/tmri0/sck2/sda1 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 pw3/a3/p13 pw2/a2/p12 pw1/a1/p11 pw0/a0/p10 cs4 /d3/pb3 cs3 /d2/pb2 hdb0/d8/p30 hdb1/d9/p31 hdb2/d10/p32 hdb3/d11/p33 hdb4/d12/p34 hdb5/d13/p35 hdb6/d14/p36 hdb7/d15/p37 hirq4/d1/pb1 hirq3/d0/pb0 vss ha0/p80 ga20/ cs2 /p81 hifsd/p82 p83 txd1/ irq3 /p84 rxd1/ irq4 /p85 scl1/sck1/ irq5 /p86 reso 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 p41/tmo0/rxd2/irrxd p40/tmci0/txd2/irtxd pa0/a16/cin8/ kin8 pa1/a17/cin9/ kin9 avss p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 avcc avref p67/tmox/cin7/ kin7 / irq7 p66/ftob/cin6/ kin6 / irq6 p65/ftid/cin5/ kin5 p64/ftic/cin4/ kin4 /clampo pa2/a18/cin10/ kin10 /ps2ac pa3/a19/cin11/ kin11 /ps2ad p63/ftib/cin3/ kin3 /vfbacki p62/ftia/cin2/ kin2 /vsynci/tmiy p61/ftoa/cin1/ kin1 /vsynco p60/ftci/cin0/ kin0 /hfbacki/tmix figure 1.2 (a) pin arrangement of h8s/2148 series (fp-100b, tfp-100b: top view)
11 fp-100b tfp-100b (top view) res xtal extal vcc1 md1 md0 nmi stby vcc2 kin15 /cin15/a23/pa7 kin14 /cin14/a22/pa6 sck0/p52 rxd0/p51 txd0/p50 vss wait /p97 excl/?p96 ios / as /p95 hwr /p94 kin13 /cin13/a21/pa5 kin12 /cin12/a20/pa4 rd /p93 irq0 /p92 irq1 /p91 adtrg / irq2 / lwr /p90 p14/a4 p15/a5 p16/a6 p17/a7 vss vss pb4/d4 pb5/d5 p20/a8 p21/a9 p22/a10 p23/a11 p24/a12 p25/a13 p26/a14 p27/a15 vcc1 pb6/d6 pb7/d7 p47/pwx1 p46/pwx0 p45/tmri1 p44/tmo1 p43/tmci1 p42/tmri0/sck2 12345678910111213141516171819202122232425 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 p41/tmo0/rxd2/irrxd p40/tmci0/txd2/irtxd pa0/a16/cin8/ kin8 pa1/a17/cin9/ kin9 avss p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 avcc avref p67/cin7/ kin7 / irq7 p66/ftob/cin6/ kin6 / irq6 p65/ftid/cin5/ kin5 p64/ftic/cin4/ kin4 pa2/a18/cin10/ kin10 pa3/a19/cin11/ kin11 p63/ftib/cin3/ kin3 p62/ftia/cin2/ kin2 /tmiy p61/ftoa/cin1/ kin1 p60/ftci/cin0/ kin0 a3/p13 a2/p12 a1/p11 a0/p10 d3/pb3 d2/pb2 d8/p30 d9/p31 d10/p32 d11/p33 d12/p34 d13/p35 d14/p36 d15/p37 d1/pb1 d0/pb0 vss p80 p81 p82 p83 txd1/ irq3 /p84 rxd1/ irq4 /p85 sck1/ irq5 /p86 reso figure 1.2 (b) pin arrangement of h8s/2144 series (fp-100b, tfp-100b: top view)
12 1.3.2 pin functions in each operating mode tables 1.2 (a) and (b) show the pin functions of the h8s/2148 series and h8s/2144 series in each of the operating modes. table 1.2 (a) h8s/2148 series pin functions in each operating mode pin name pin no. expanded modes single-chip modes fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) flash memory writer mode 1 5(6 5(6 5(6 5(6 2 xtal xtal xtal xtal 3 extal extal extal extal 4 vccb vccb vccb vcc 5 md1 md1 md1 vss 6 md0 md0 md0 vss 7 nmi nmi nmi fa9 8 67%< 67%< 67%< vcc 9 vcc2 vcc2 vcc2 vcc 10 pa7/cin15/ .,1 /ps2cd a23/pa7/cin15/ .,1 /ps2cd pa7/cin15/ .,1 /ps2cd nc 11 pa6/cin14/ .,1 /ps2cc a22/pa6/cin14/ .,1 /ps2cc pa6/cin14/ .,1 /ps2cc nc 12 p52/sck0/scl0 p52/sck0/scl0 p52/sck0/scl0 nc 13 p51/rxd0 p51/rxd0 p51/rxd0 fa17 14 p50/txd0 p50/txd0 p50/txd0 nc 15 vss vss vss vss 16 p97/ :$,7 /sda0 p97/ :$,7 /sda0 p97/sda0 vcc 17 ?/p96/excl ?/p96/excl p96/?/excl nc 18 $6 / ,26 $6 / ,26 p95/ &6 fa16 19 +:5 +:5 p94/ ,2: fa15 20 pa5/cin13/ .,1 /ps2bd a21/pa5/cin13/ .,1 /ps2bd pa5/cin13/ .,1 /ps2bd nc 21 pa4/cin12/ .,1 /ps2bc a20/pa4/cin12/ .,1 /ps2bc pa4/cin12/ .,1 /ps2bc nc 22 5' 5' p93/ ,25 :( 23 p92/ ,54 p92/ ,54 p92/ ,54 vss 24 p91/ ,54 p91/ ,54 p91/ ,54 vcc
13 table 1.2 (a) h8s/2148 series pin functions in each operating mode (cont) pin name pin no. expanded modes single-chip modes fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) flash memory writer mode 25 /:5 /p90/ ,54 / $'75* /:5 /p90/ ,54 / $'75* p90/ ,54 / $'75* / (&6 vcc 26 p60/ftci/cin0/ .,1 /tmix/ hfbacki p60/ftci/cin0/ .,1 /tmix/ hfbacki p60/ftci/cin0/ .,1 /tmix/ hfbacki nc 27 p61/ftoa/cin1/ .,1 /vsynco p61/ftoa/cin1/ .,1 /vsynco p61/ftoa/cin1/ .,1 /vsynco nc 28 p62/ftia/cin2/ .,1 /tmiy/ vsynci p62/ftia/cin2/ .,1 /tmiy/ vsynci p62/ftia/cin2/ .,1 /tmiy/ vsynci nc 29 p63/ftib/cin3/ .,1 /vfbacki p63/ftib/cin3/ .,1 /vfbacki p63/ftib/cin3/ .,1 /vfbacki nc 30 pa3/cin11/ .,1 /ps2ad a19/pa3/cin11/ .,1 /ps2ad pa3/cin11/ .,1 /ps2ad nc 31 pa2/cin10/ .,1 /ps2ac a18/pa2/cin10/ .,1 /ps2ac pa2/cin10/ .,1 /ps2ac nc 32 p64/ftic/cin4/ .,1 /clampo p64/ftic/cin4/ .,1 /clampo p64/ftic/cin4/ .,1 /clampo nc 33 p65/ftid/cin5/ .,1 p65/ftid/cin5/ .,1 p65/ftid/cin5/ .,1 nc 34 p66/ftob/cin6/ .,1 / ,54 p66/ftob/cin6/ .,1 / ,54 p66/ftob/cin6/ .,1 / ,54 nc 35 p67/tmox/cin/ .,1 / ,54 p67/tmox/cin7/ .,1 / ,54 p67/tmox/cin7/ .,1 / ,54 vss 36 avref avref avref vcc 37 avcc avcc avcc vcc 38 p70/an0 p70/an0 p70/an0 nc 39 p71/an1 p71/an1 p71/an1 nc 40 p72/an2 p72/an2 p72/an2 nc 41 p73/an3 p73/an3 p73/an3 nc 42 p74/an4 p74/an4 p74/an4 nc 43 p75/an5 p75/an5 p75/an5 nc 44 p76/an6/da0 p76/an6/da0 p76/an6/da0 nc 45 p77/an7/da1 p77/an7/da1 p77/an7/da1 nc
14 table 1.2 (a) h8s/2148 series pin functions in each operating mode (cont) pin name pin no. expanded modes single-chip modes fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) flash memory writer mode 46 avss avss avss vss 47 pa1/cin9/ .,1 a17/pa1/cin9/ .,1 pa1/cin9/ .,1 nc 48 pa0/cin8/ .,1 a16/pa0/cin8/ .,1 pa0/cin8/ .,1 nc 49 p40/tmci0/ txd2/irtxd p40/tmci0/ txd2/irtxd p40/tmci0/ txd2/irtxd nc 50 p41/tmo0/ rxd2/irrxd p41/tmo0/ rxd2/irrxd p41/tmo0/ rxd2/irrxd nc 51 p42/tmri0/ sck2/sda1 p42/tmri0/ sck2/sda1 p42/tmri0/ sck2/sda1 nc 52 p43/tmci1/ hsynci p43/tmci1/ hsynci p43/tmci1/hirq11/ hsynci nc 53 p44/tmo1/ hsynco p44/tmo1/ hsynco p44/tmo1/hirq1/ hsynco nc 54 p45/tmri1/ csynci p45/tmri1/ csynci p45/tmri1/hirq12/ csynci nc 55 p46/pwx0 p46/pwx0 p46/pwx0 nc 56 p47/pwx1 p47/pwx1 p47/pwx1 nc 57 pb7/d7 pb7/d7 pb7 nc 58 pb6/d6 pb6/d6 pb6 nc 59 vcc1 vcc1 vcc1 vcc 60 a15 a15/p27/pw15/ cblank p27/pw15/cblank &( 61 a14 a14/p26/pw14 p26/pw14 fa14 62 a13 a13/p25/pw13 p25/pw13 fa13 63 a12 a12/p24/pw12 p24/pw12 fa12 64 a11 a11/p23/pw11 p23/pw11 fa11 65 a10 a10/p22/pw10 p22/pw10 fa10 66 a9 a9/p21/pw9 p21/pw9 2( 67 a8 a8/p20/pw8 p20/pw8 fa8 68 pb5/d5 pb5/d5 pb5 nc 69 pb4/d4 pb4/d4 pb4 nc 70 vss vss vss vss
15 table 1.2 (a) h8s/2148 series pin functions in each operating mode (cont) pin name pin no. expanded modes single-chip modes fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) flash memory writer mode 71 vss vss vss vss 72 a7 a7/p17/pw7 p17/pw7 fa7 73 a6 a6/p16/pw6 p16/pw6 fa6 74 a5 a5/p15/pw5 p15/pw5 fa5 75 a4 a4/p14/pw4 p14/pw4 fa4 76 a3 a3/p13/pw3 p13/pw3 fa3 77 a2 a2/p12/pw2 p12/pw2 fa2 78 a1 a1/p11/pw1 p11/pw1 fa1 79 a0 a0/p10/pw0 p10/pw0 fa0 80 pb3/d3 pb3/d3 pb3/ &6 nc 81 pb2/d2 pb2/d2 pb2/ &6 nc 82 d8 d8 p30/hdb0 fo0 83 d9 d9 p31/hdb1 fo1 84 d10 d10 p32/hdb2 fo2 85 d11 d11 p33/hdb3 fo3 86 d12 d12 p34/hdb4 fo4 87 d13 d13 p35/hdb5 fo5 88 d14 d14 p36/hdb6 fo6 89 d15 d15 p37/hdb7 fo7 90 pb1/d1 pb1/d1 pb1/hirq4 nc 91 pb0/d0 pb0/d0 pb0/hirq3 nc 92 vss vss vss vss 93 p80 p80 p80/ha0 nc 94 p81 p81 p81/ &6 /ga20 nc 95 p82 p82 p82 nc 96 p83 p83 p83 nc 97 p84/ ,54 /txd1 p84/ ,54 /txd1 p84/ ,54 /txd1 nc 98 p85/ ,54 /rxd1 p85/ ,54 /rxd1 p85/ ,54 /rxd1 nc 99 p86/ ,54 /sck1/ scl1 p86/ ,54 /sck1/ scl1 p86/ ,54 /sck1/ scl1 nc 100 5(62 5(62 5(62 nc
16 table 1.2 (b) h8s/2144 series pin functions in each operating mode pin name pin no. expanded modes single-chip modes fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) flash memory writer mode 1 5(6 5(6 5(6 5(6 2 xtal xtal xtal xtal 3 extal extal extal extal 4 vcc1 vcc1 vcc1 vcc 5 md1 md1 md1 vss 6 md0 md0 md0 vss 7 nmi nmi nmi fa9 8 67%< 67%< 67%< vcc 9 vcc2 vcc2 vcc2 vcc 10 pa7/cin15/ .,1 a23/pa7/cin15/ .,1 pa7/cin15/ .,1 nc 11 pa6/cin14/ .,1 a22/pa6/cin14/ .,1 pa6/cin14/ .,1 nc 12 p52/sck0 p52/sck0 p52/sck0 nc 13 p51/rxd0 p51/rxd0 p51/rxd0 fa17 14 p50/txd0 p50/txd0 p50/txd0 nc 15 vss vss vss vss 16 p97/ :$,7 p97/ :$,7 p97 vcc 17 ?/p96/excl ?/p96/excl p96/?/excl nc 18 $6 / ,26 $6 / ,26 p95 fa16 19 +:5 +:5 p94 fa15 20 pa5/cin13/ .,1 a21/pa5/cin13/ .,1 pa5/cin13/ .,1 nc 21 pa4/cin12/ .,1 a20/pa4/cin12/ .,1 pa4/cin12/ .,1 nc 22 5' 5' p93 :( 23 p92/ ,54 p92/ ,54 p92/ ,54 vss 24 p91/ ,54 p91/ ,54 p91/ ,54 vcc 25 /:5 /p90/ ,54 / $'75* /:5 /p90/ ,54 / $'75* p90/ ,54 / $'75* vcc 26 p60/ftci/cin0/ .,1 p60/ftci/cin0/ .,1 p60/ftci/cin0/ .,1 nc
17 table 1.2 (b) h8s/2144 series pin functions in each operating mode (cont) pin name pin no. expanded modes single-chip modes fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) flash memory writer mode 27 p61/ftoa/ cin1/ .,1 p61/ftoa/cin1/ .,1 p61/ftoa/cin1/ .,1 nc 28 p62/ftia/cin2/ .,1 /tmiy p62/ftia/cin2/ .,1 /tmiy p62/ftia/cin2/ .,1 /tmiy nc 29 p63/ftib/cin3/ .,1 p63/ftib/cin3/ .,1 p63/ftib/cin3/ .,1 nc 30 pa3/cin11/ .,1 a19/pa3/cin11/ .,1 pa3/cin11/ .,1 nc 31 pa2/cin10/ .,1 a18/pa2/cin10/ .,1 pa2/cin10/ .,1 nc 32 p64/ftic/cin4/ .,1 p64/ftic/cin4/ .,1 p64/ftic/cin4/ .,1 nc 33 p65/ftid/cin5/ .,1 p65/ftid/cin5/ .,1 p65/ftid/cin5/ .,1 nc 34 p66/ftob/cin6/ .,1 / ,54 p66/ftob/cin6/ .,1 / ,54 p66/ftob/cin6/ .,1 / ,54 nc 35 p67/cin7/ .,1 / ,54 p67/cin7/ .,1 / ,54 p67/cin7/ .,1 / ,54 vss 36 avref avref avref vcc 37 avcc avcc avcc vcc 38 p70/an0 p70/an0 p70/an0 nc 39 p71/an1 p71/an1 p71/an1 nc 40 p72/an2 p72/an2 p72/an2 nc 41 p73/an3 p73/an3 p73/an3 nc 42 p74/an4 p74/an4 p74/an4 nc 43 p75/an5 p75/an5 p75/an5 nc 44 p76/an6/da0 p76/an6/da0 p76/an6/da0 nc 45 p77/an7/da1 p77/an7/da1 p77/an7/da1 nc 46 avss avss avss vss 47 pa1/cin9/ .,1 a17/pa1/cin9/ .,1 pa1/cin9/ .,1 nc 48 pa0/cin8/ .,1 a16/pa0/cin8/ .,1 pa0/cin8/ .,1 nc
18 table 1.2 (b) h8s/2144 series pin functions in each operating mode (cont) pin name pin no. expanded modes single-chip modes fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) flash memory writer mode 49 p40/tmci0/ txd2/irtxd p40/tmci0/ txd2/irtxd p40/tmci0/ txd2/irtxd nc 50 p41/tmo0/ rxd2/irrxd p41/tmo0/ rxd2/irrxd p41/tmo0/ rxd2/irrxd nc 51 p42/tmri0/ sck2 p42/tmri0/ sck2 p42/tmri0/ sck2 nc 52 p43/tmci1 p43/tmci1 p43/tmci1 nc 53 p44/tmo1 p44/tmo1 p44/tmo1 nc 54 p45/tmri1 p45/tmri1 p45/tmri1 nc 55 p46/pwx0 p46/pwx0 p46/pwx0 nc 56 p47/pwx1 p47/pwx1 p47/pwx1 nc 57 pb7/d7 pb7/d7 pb7 nc 58 pb6/d6 pb6/d6 pb6 nc 59 vcc1 vcc1 vcc1 vcc 60 a15 a15/p27 p27 &( 61 a14 a14/p26 p26 fa14 62 a13 a13/p25 p25 fa13 63 a12 a12/p24 p24 fa12 64 a11 a11/p23 p23 fa11 65 a10 a10/p22 p22 fa10 66 a9 a9/p21 p21 2( 67 a8 a8/p20 p20 fa8 68 pb5/d5 pb5/d5 pb5 nc 69 pb4/d4 pb4/d4 pb4 nc 70 vss vss vss vss 71 vss vss vss vss 72 a7 a7/p17 p17 fa7 73 a6 a6/p16 p16 fa6 74 a5 a5/p15 p15 fa5 75 a4 a4/p14 p14 fa4 76 a3 a3/p13 p13 fa3
19 table 1.2 (b) h8s/2144 series pin functions in each operating mode (cont) pin name pin no. expanded modes single-chip modes fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) flash memory writer mode 77 a2 a2/p12 p12 fa2 78 a1 a1/p11 p11 fa1 79 a0 a0/p10 p10 fa0 80 pb3/d3 pb3/d3 pb3 nc 81 pb2/d2 pb2/d2 pb2 nc 82 d8 d8 p30 fo0 83 d9 d9 p31 fo1 84 d10 d10 p32 fo2 85 d11 d11 p33 fo3 86 d12 d12 p34 fo4 87 d13 d13 p35 fo5 88 d14 d14 p36 fo6 89 d15 d15 p37 fo7 90 pb1/d1 pb1/d1 pb1 nc 91 pb0/d0 pb0/d0 pb0 nc 92 vss vss vss vss 93 p80 p80 p80 nc 94 p81 p81 p81 nc 95 p82 p82 p82 nc 96 p83 p83 p83 nc 97 p84/ ,54 /txd1 p84/ ,54 /txd1 p84/ ,54 /txd1 nc 98 p85/ ,54 /rxd1 p85/ ,54 /rxd1 p85/ ,54 /rxd1 nc 99 p86/ ,54 /sck1 p86/ ,54 /sck1 p86/ ,54 /sck1 nc 100 5(62 5(62 5(62 nc
20 1.3.3 pin functions table 1.3 summarizes the functions of the h8s/2148 series and h8s/2144 series pins. table 1.3 pin functions pin no. type symbol fp-100b tfp-100b i/o name and function power supply vcc1 vcc2 4 [h8s/2144 series only], 59 9 input power supply: for connection to the power supply. all vcc1 and vcc2 pins should be connected to the system power supply. vccb 4 [h8s/2148 series only] input input/output buffer power supply: power supply pin for the port a input/output buffer. vss 15, 70 71, 92 input ground: all vss pins should be connected to the system power supply (0 v). clock xtal 2 input connected to a crystal oscillator. see section 23, clock pulse generator, for typical connection diagrams for a crystal oscillator and external clock input. extal 3 input connected to a crystal oscillator. the extal pin can also input an external clock. see section 23, clock pulse generator, for typical connection diagrams for a crystal oscillator and external clock input. ? 17 output system clock: supplies the system clock to external devices. excl 17 input external subclock input: input a 32.768 khz external subclock.
21 table 1.3 pin functions (cont) pin no. type symbol fp-100b tfp-100b i/o name and function operating mode control md1 md0 5 6 input mode pins: these pins set the operating mode. the relation between the settings of pins md1 and md0 and the operating mode is shown below. these pins should not be changed while the mcu is operating. md1 md0 operating mode description 0 1 mode 1 normal expanded mode with on-chip rom disabled 1 0 mode 2 advanced expanded mode with on-chip rom enabled or single-chip mode 1 1 mode 3 normal expanded mode with on-chip rom enabled or single-chip mode system control 5(6 1 input reset input: when this pin is driven low, the chip is reset. 5(62 100 output reset output: outputs reset signal to external device. 67%< 8 input standby: when this pin is driven low, a transition is made to hardware standby mode. address bus a23 to a16 10, 11, 20, 21, 30, 31, 47, 48 output address bus (advanced): outputs address when 16-mbyte space is used. a15 to a0 60 to 67, 72 to 79 output address bus: these pins output an address. data bus d15 to d8 89 to 82 input/ output data bus (upper): bidirectional data bus. used for 8-bit data and upper byte of 16-bit data. d7 to d0 57, 58, 68, 69, 80, 81, 90, 91 input/ output data bus (lower): bidirectional data bus. used for lower byte of 16-bit data.
22 table 1.3 pin functions (cont) pin no. type symbol fp-100b tfp-100b i/o name and function bus control :$,7 16 input wait: requests insertion of a wait state in the bus cycle when accessing external 3-state address space. 5' 22 output read: when this pin is low, it indicates that the external address space is being read. +:5 19 output high write: when this pin is low, it indicates that the external address space is being written to. the upper half of the data bus is valid. /:5 25 output low write: when this pin is low, it indicates that the external address space is being written to. the lower half of the data bus is valid. $6 / ,26 18 output address strobe: when this pin is low, it indicates that address output on the address bus is valid. interrupt signals nmi 7 input nonmaskable interrupt: requests a nonmaskable interrupt. ,54 to ,54 23 to 25, 97 to 99, 34, 35 input interrupt request 0 to 7: these pins request a maskable interrupt. 16-bit free- running timer ftci 26 input frt counter clock input: input pin for an external clock signal for the free-running counter (frc). (frt) ftoa 27 output frt output compare a output: the output compare a output pin. ftob 34 output frt output compare b output: the output compare b output pin. ftia 28 input frt input capture a input: the input capture a input pin. ftib 29 input frt input capture b input: the input capture b input pin. ftic 32 input frt input capture c input: the input capture c input pin. ftid 33 input frt input capture d input: the input capture d input pin.
23 table 1.3 pin functions (cont) pin no. type symbol fp-100b tfp-100b i/o name and function 8-bit timer (tmr0, tmr1, tmo0 tmo1 tmox 50 53 35 output compare-match output: tmr0, tmr1, and tmrx compare-match output pins. tmrx, tmry) tmci0 tmci1 49 52 input counter external clock input: input pins for the external clock input to the tmr0 and tmr1 counters. tmri0 tmri1 51 54 input counter external reset input: tmr0 and tmr1 counter reset input pins. tmix tmiy 26 28 input counter external clock input and reset input: dual function as tmrx and tmry counter clock input pin and reset input pin. pwm timer (pwm) pw15 to pw0 60 to 67, 72 to 79 output pwm timer output: pwm timer pulse output pins. 14-bit pwm timer (pwmx) pwx0 pwx1 55 56 output pwmx timer output: pwm d/a pulse output pins. serial com- munication interface txd0 txd1 txd2 14 97 49 output transmit data: data output pins. (sci0, sci1, sci2) rxd0 rxd1 rxd2 13 98 50 input receive data: data input pins. sck0 sck1 sck2 12 99 51 input/ output serial clock: clock input/output pins. the sck0 output type is nmos push-pull. sci with irda (sci2) irtxd irrxd 49 50 output input irda transmit data/receive data: input and output pins for data encoded for irda use. keyboard buffer controller ps2ac ps2bc ps2cc 31 21 11 input/ output ps2 clock: keyboard buffer controller synchronization clock input/output pins. (ps2) ps2ad ps2bd ps2cd 30 20 10 input/ output ps2 data: keyboard buffer controller data input/output pins.
24 table 1.3 pin functions (cont) pin no. type symbol fp-100b tfp-100b i/o name and function host interface (hif) hdb7 to hdb0 89 to 82 input/ output host interface data bus: bidirectional 8-bit bus for accessing the host interface. &6 , &6 , (&6 &6 , &6 18, 94, 25 81, 80 input chip select 1, 2, 3, and 4: input pins for selecting host interface channel 1 to 4. ,25 22 input i/o read: input pin that enables reading from the host interface. ,2: 19 input i/o write: input pin that enables writing to the host interface. ha0 93 input command/data: input pin that indicates whether an access is a data access or command access. ga20 94 output gate a20: a20 gate control signal output pin. hirq11 hirq1 hirq12 hirq3 hirq4 52 53 54 91 90 output host interrupt 11, 1, and 12: output pins for interrupt requests to the host. hifsd 95 input host interface shutdown: control input pin used to place host interface input/output pins in the high- impedance/cutoff state. keyboard control .,1 to .,1 26 to 29, 32 to 35, 48, 47, 31, 30, 21, 20, 11, 10 input keyboard input: matrix keyboard input pins. normally, p10 to p17 and p20 to p27 are used as key-scan outputs. this enables a maximum 16- output 16-input, 256-key matrix to be configured. a/d converter (adc) an7 to an0 45 to 38 input analog input: a/d converter analog input pins. cin0 to cin15 26 to 29, 32 to 35, 48, 47, 31, 30, 21, 20, 11, 10 input expansion a/d inputs: expansion a/d input pins can be connected to the a/d converter, but since they are also used as digital input/output pins, precision will fall. $'75* 25 input a/d conversion external trigger input: pin for input of an external trigger to start a/d conversion.
25 table 1.3 pin functions (cont) pin no. type symbol fp-100b tfp-100b i/o name and function d/a converter (dac) da0 da1 44 45 output analog output: d/a converter analog output pins. a/d converter d/a converter avcc 37 input analog reference voltage: the analog power supply pin for the a/d converter and d/a converter. when the a/d and d/a converters are not used, this pin should be connected to the system power supply (+5 v or +3 v). avref 36 input analog reference voltage: the reference power supply pin for the a/d converter and d/a converter. when the a/d and d/a converters are not used, this pin should be connected to the system power supply (+5 v or +3 v). avss 46 input analog ground: the ground pin for the a/d converter and d/a converter. this pin should be connected to the system power supply (0 v). timer connection vsynci, hsynci, csynci, vfbacki, hfbacki 28 52 54 29 26 input timer connection input: timer connection synchronous signal input pins. vsynco, hsynco, clampo, cblank 27 53 32 60 output timer connection output: timer connection synchronous signal output pins. i 2 c bus interface (iic) (option) scl0 scl1 12 99 input/ output i 2 c clock input/output (channels 0 and 1): i 2 c clock i/o pins. these pins have a bus drive function. the scl0 output form is nmos open-drain sda0 sda1 16 51 input/ output i 2 c data input/output (channels 0 and 1): i 2 c data i/o pins. these pins have a bus drive function. the sda0 output form is nmos open-drain. i/o ports p17 to p10 72 to 79 input/ output port 1: eight input/output pins. the data direction of each pin can be selected in the port 1 data direction register (p1ddr). these pins have built-in mos input pull-ups, and also have led drive capability.
26 table 1.3 pin functions (cont) pin no. type symbol fp-100b tfp-100b i/o name and function i/o ports p27 to p20 60 to 67 input/ output port 2: eight input/output pins. the data direction of each pin can be selected in the port 2 data direction register (p2ddr). these pins have built-in mos input pull-ups, and also have led drive capability. p37 to p30 89 to 82 input/ output port 3: eight input/output pins. the data direction of each pin can be selected in the port 3 data direction register (p3ddr). these pins have built-in mos input pull-ups, and also have led drive capability. p47 to p40 56 to 49 input/ output port 4: eight input/output pins. the data direction of each pin can be selected in the port 4 data direction register (p4ddr). p52 to p50 12 to 14 input/ output port 5: three input/output pins. the data direction of each pin can be selected in the port 5 data direction register (p5ddr). p52 is an nmos push- pull output. [h8s/2148 series only] p67 to p60 35 to 32 29 to 26 input/ output port 6: eight input/output pins. the data direction of each pin can be selected in the port 6 data direction register (p6ddr). these pins have built-in mos input pull-ups. p77 to p70 45 to 38 input port 7: eight input pins. p86 to p80 99 to 93 input/ output port 8: seven input/output pins. the data direction of each pin can be selected in the port 8 data direction register (p8ddr). p97 to p90 16 to 19 22 to 25 input/ output port 9: eight input/output pins. the data direction of each pin (except p96) can be selected in the port 9 data direction register (p9ddr). p97 is an nmos push-pull output. [h8s/2148 series only] pa7 to pa0 10, 11, 20, 21, 30, 31, 47, 48 input/ output port a: eight input/output pins. the data direction of each pin can be selected in the port a data direction register (paddr). these pins have built- in mos input pull-ups. [h8s/2148 series only] pb7 to pb0 57, 58, 68, 69, 80, 81, 90, 91 input/ output port b: eight input/output pins. the data direction of each pin can be selected in the port b data direction register (pbddr). these pins have built- in mos input pull-ups.
27 section 2 cpu 2.1 overview the h8s/2000 cpu is a high-speed central processing unit with an internal 32-bit architecture that is upward-compatible with the h8/300 and h8/300h cpus. the h8s/2000 cpu has sixteen 16-bit general registers, can address a 16-mbyte (architecturally 4-gbyte) linear address space, and is ideal for realtime control. 2.1.1 features the h8s/2000 cpu has the following features. upward-compatible with h8/300 and h8/300h cpus ? can execute h8/300 and h8/300h object programs general-register architecture ? sixteen 16-bit general registers (also usable as sixteen 8-bit registers or eight 32-bit registers) sixty-five basic instructions ? 8/16/32-bit arithmetic and logic instructions ? multiply and divide instructions ? powerful bit-manipulation instructions eight addressing modes ? register direct [rn] ? register indirect [@ern] ? register indirect with displacement [@(d:16,ern) or @(d:32,ern)] ? register indirect with post-increment or pre-decrement [@ern+ or @Cern] ? absolute address [@aa:8, @aa:16, @aa:24, or @aa:32] ? immediate [#xx:8, #xx:16, or #xx:32] ? program-counter relative [@(d:8,pc) or @(d:16,pc)] ? memory indirect [@@aa:8] 16-mbyte address space ? program: 16 mbytes ? data: 16 mbytes (4 gbytes architecturally)
28 high-speed operation ? all frequently-used instructions execute in one or two states ? maximum clock rate: 20 mhz ? 8/16/32-bit register-register add/subtract: 50 ns ? 8 8-bit register-register multiply: 600 ns ? 16 8-bit register-register divide: 600 ns ? 16 16-bit register-register multiply: 1000 ns ? 32 16-bit register-register divide: 1000 ns two cpu operating modes ? normal mode ? advanced mode power-down state ? transition to power-down state by sleep instruction ? cpu clock speed selection 2.1.2 differences between h8s/2600 cpu and h8s/2000 cpu the differences between the h8s/2600 cpu and the h8s/2000 cpu are shown below. register configuration the mac register is supported only by the h8s/2600 cpu. basic instructions the four instructions mac, clrmac, ldmac, and stmac are supported only by the h8s/2600 cpu. number of execution states the number of execution states of the mulxu and mulxs instructions differ as follows. number of execution states instruction mnemonic h8s/2600 h8s/2000 mulxu mulxu.b rs, rd 3 12 mulxu.w rs, erd 4 20 mulxs mulxs.b rs, rd 4 13 mulxs.w rs, erd 5 21 there are also differences in the address space, exr register functions, power-down state, etc., depending on the product.
29 2.1.3 differences from h8/300 cpu in comparison to the h8/300 cpu, the h8s/2000 cpu has the following enhancements. more general registers and control registers ? eight 16-bit extended registers, and one 8-bit control register, have been added. expanded address space ? normal mode supports the same 64-kbyte address space as the h8/300 cpu. ? advanced mode supports a maximum 16-mbyte address space. enhanced addressing ? the addressing modes have been enhanced to make effective use of the 16-mbyte address space. enhanced instructions ? addressing modes of bit-manipulation instructions have been enhanced. ? signed multiply and divide instructions have been added. ? two-bit shift instructions have been added. ? instructions for saving and restoring multiple registers have been added. ? a test and set instruction has been added. higher speed ? basic instructions execute twice as fast. 2.1.4 differences from h8/300h cpu in comparison to the h8/300h cpu, the h8s/2000 cpu has the following enhancements. additional control register ? one 8-bit control register has been added. enhanced instructions ? addressing modes of bit-manipulation instructions have been enhanced. ? two-bit shift instructions have been added. ? instructions for saving and restoring multiple registers have been added. ? a test and set instruction has been added. higher speed ? basic instructions execute twice as fast.
30 2.2 cpu operating modes the h8s/2000 cpu has two operating modes: normal and advanced. normal mode supports a maximum 64-kbyte address space. advanced mode supports a maximum 16-mbyte total address space (architecturally the maximum total address space is 4 gbytes, with a maximum of 16 mbytes for the program area and a maximum of 4 gbytes for the data area). the mode is selected by the mode pins of the microcontroller. cpu operating modes normal mode advanced mode maximum 64 kbytes for program and data areas combined maximum 16 mbytes for program and data areas combined figure 2.1 cpu operating modes (1) normal mode the exception vector table and stack have the same structure as in the h8/300 cpu. address space: a maximum address space of 64 kbytes can be accessed. extended registers (en): the extended registers (e0 to e7) can be used as 16-bit registers, or as the upper 16-bit segments of 32-bit registers. when en is used as a 16-bit register it can contain any value, even when the corresponding general register (rn) is used as an address register. if the general register is referenced in the register indirect addressing mode with pre- decrement (@Crn) or post-increment (@rn+) and a carry or borrow occurs, however, the value in the corresponding extended register (en) will be affected. instruction set: all instructions and addressing modes can be used. only the lower 16 bits of effective addresses (ea) are valid.
31 exception vector table and memory indirect branch addresses: in normal mode the top area starting at h'0000 is allocated to the exception vector table. one branch address is stored per 16 bits. the configuration of the exception vector table in normal mode is shown in figure 2.2. for details of the exception vector table, see section 4, exception handling. h'0000 h'0001 h'0002 h'0003 h'0004 h'0005 h'0006 h'0007 h'0008 h'0009 h'000a h'000b reset exception vector exception vector 1 exception vector 2 exception vector table (reserved for system use) figure 2.2 exception vector table (normal mode) the memory indirect addressing mode (@@aa:8) employed in the jmp and jsr instructions uses an 8-bit absolute address included in the instruction code to specify a memory operand that contains a branch address. in normal mode the operand is a 16-bit word operand, providing a 16- bit branch address. branch addresses can be stored in the top area from h'0000 to h'00ff. note that this area is also used for the exception vector table.
32 stack structure: when the program counter (pc) is pushed onto the stack in a subroutine call, and the pc and condition-code register (ccr) are pushed onto the stack in exception handling, they are stored as shown in figure 2.3. the extended control register (exr) is not pushed onto the stack. for details, see section 4, exception handling. (a) subroutine branch (b) exception handling pc (16 bits) ccr ccr * pc (16 bits) sp note: * ignored when returning. sp figure 2.3 stack structure in normal mode (2) advanced mode address space: linear access is provided to a 16-mbyte maximum address space (architecturally a maximum 16-mbyte program area and a maximum 4-gbyte data area, with a maximum of 4 gbytes for program and data areas combined). extended registers (en): the extended registers (e0 to e7) can be used as 16-bit registers, or as the upper 16-bit segments of 32-bit registers or address registers. instruction set: all instructions and addressing modes can be used.
33 exception vector table and memory indirect branch addresses: in advanced mode the top area starting at h'00000000 is allocated to the exception vector table in units of 32 bits. in each 32 bits, the upper 8 bits are ignored and a branch address is stored in the lower 24 bits (figure 2.4). for details of the exception vector table, see section 4, exception handling. h'00000000 h'00000003 h'00000004 h'0000000b h'0000000c exception vector table reserved reset exception vector (reserved for system use) reserved exception vector 1 reserved h'00000010 h'00000008 h'00000007 figure 2.4 exception vector table (advanced mode) the memory indirect addressing mode (@@aa:8) employed in the jmp and jsr instructions uses an 8-bit absolute address included in the instruction code to specify a memory operand that contains a branch address. in advanced mode the operand is a 32-bit longword operand, providing a 32-bit branch address. the upper 8 bits of these 32 bits are a reserved area that is regarded as h'00. branch addresses can be stored in the area from h'00000000 to h'000000ff. note that the first part of this range is also the exception vector table.
34 stack structure: in advanced mode, when the program counter (pc) is pushed onto the stack in a subroutine call, and the pc and condition-code register (ccr) are pushed onto the stack in exception handling, they are stored as shown in figure 2.5. the extended control register (exr) is not pushed onto the stack. for details, see section 4, exception handling. (a) subroutine branch (b) exception handling pc (24 bits) ccr pc (24 bits) sp sp reserved figure 2.5 stack structure in advanced mode
35 2.3 address space figure 2.6 shows a memory map of the h8s/2000 cpu. the h8s/2000 cpu provides linear access to a maximum 64-kbyte address space in normal mode, and a maximum 16-mbyte (architecturally 4-gbyte) address space in advanced mode. (b) advanced mode h'0000 h'ffff h'00000000 h'ffffffff h'00ffffff (a) normal mode data area program area cannot be used by the h8s/2148 series or h8s/2144 series figure 2.6 memory map
36 2.4 register configuration 2.4.1 overview the cpu has the internal registers shown in figure 2.7. there are two types of registers: general registers and control registers. t i2 i1 i0 exr * 76543210 pc 23 0 15 07 07 0 e0 e1 e2 e3 e4 e5 e6 e7 r0h r1h r2h r3h r4h r5h r6h r7h r0l r1l r2l r3l r4l r5l r6l r7l general registers (rn) and extended registers (en) control registers (cr) legend: stack pointer program counter extended control register trace bit interrupt mask bits condition-code register interrupt mask bit user bit or interrupt mask bit sp: pc: exr: t: i2 to i0: ccr: i: ui: note: * does not affect operation in the h8s/2148 series and h8s/2144 series. er0 er1 er2 er3 er4 er5 er6 er7 (sp) i ui hunzvc ccr 76543210 half-carry flag user bit negative flag zero flag overflow flag carry flag h: u: n: z: v: c: figure 2.7 cpu registers
37 2.4.2 general registers the cpu has eight 32-bit general registers. these general registers are all functionally alike and can be used as both address registers and data registers. when a general register is used as a data register, it can be accessed as a 32-bit, 16-bit, or 8-bit register. when the general registers are used as 32-bit registers or address registers, they are designated by the letters er (er0 to er7). the er registers divide into 16-bit general registers designated by the letters e (e0 to e7) and r (r0 to r7). these registers are functionally equivalent, providing a maximum of sixteen 16-bit registers. the e registers (e0 to e7) are also referred to as extended registers. the r registers divide into 8-bit general registers designated by the letters rh (r0h to r7h) and rl (r0l to r7l). these registers are functionally equivalent, providing a maximum of sixteen 8-bit registers. figure 2.8 illustrates the usage of the general registers. the usage of each register can be selected independently. ? address registers ? 32-bit registers ? 16-bit registers ? 8-bit registers er registers (er0 to er7) e registers (extended registers) (e0 to e7) r registers (r0 to r7) rh registers (r0h to r7h) rl registers (r0l to r7l) figure 2.8 usage of general registers general register er7 has the function of stack pointer (sp) in addition to its general-register function, and is used implicitly in exception handling and subroutine calls. figure 2.9 shows the stack.
38 free area stack area sp (er7) figure 2.9 stack 2.4.3 control registers the control registers are the 24-bit program counter (pc), 8-bit extended control register (exr), and 8-bit condition-code register (ccr). (1) program counter (pc): this 24-bit counter indicates the address of the next instruction the cpu will execute. the length of all cpu instructions is 2 bytes (one word), so the least significant pc bit is ignored. (when an instruction is fetched, the least significant pc bit is regarded as 0.) (2) extended control register (exr): an 8-bit register. in the h8s/2148 series and h8s/2144 series, this register does not affect operation. bit 7trace bit (t): this bit is reserved. in the h8s/2148 series and h8s/2144 series, this bit does not affect operation. bits 6 to 3reserved: these bits are reserved. they are always read as 1. bits 2 to 0interrupt mask bits (i2 to i0): these bits are reserved. in the h8s/2148 series and h8s/2144 series, these bits do not affect operation. (3) condition-code register (ccr): this 8-bit register contains internal cpu status information, including an interrupt mask bit (i) and half-carry (h), negative (n), zero (z), overflow (v), and carry (c) flags. bit 7interrupt mask bit (i): masks interrupts other than nmi when set to 1. (nmi is accepted regardless of the i bit setting.) the i bit is set to 1 by hardware at the start of an exception-handling sequence. for details, refer to section 5, interrupt controller.
39 bit 6user bit or interrupt mask bit (ui): can be written and read by software using the ldc, stc, andc, orc, and xorc instructions. this bit can also be used as an interrupt mask bit. for details, refer to section 5, interrupt controller. bit 5half-carry flag (h): when the add.b, addx.b, sub.b, subx.b, cmp.b, or neg.b instruction is executed, this flag is set to 1 if there is a carry or borrow at bit 3, and cleared to 0 otherwise. when the add.w, sub.w, cmp.w, or neg.w instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 11, and cleared to 0 otherwise. when the add.l, sub.l, cmp.l, or neg.l instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 27, and cleared to 0 otherwise. bit 4user bit (u): can be written and read by software using the ldc, stc, andc, orc, and xorc instructions. bit 3negative flag (n): stores the value of the most significant bit (sign bit) of data. bit 2zero flag (z): set to 1 to indicate zero data, and cleared to 0 to indicate non-zero data. bit 1overflow flag (v): set to 1 when an arithmetic overflow occurs, and cleared to 0 otherwise. bit 0carry flag (c): set to 1 when a carry occurs, and cleared to 0 otherwise. used by: add instructions, to indicate a carry subtract instructions, to indicate a borrow shift and rotate instructions, to store the carry the carry flag is also used as a bit accumulator by bit-manipulation instructions. some instructions leave some or all of the flag bits unchanged. for the action of each instruction on the flag bits, refer to appendix a.1, list of instructions. operations can be performed on the ccr bits by the ldc, stc, andc, orc, and xorc instructions. the n, z, v, and c flags are used as branching conditions for conditional branch (bcc) instructions. 2.4.4 initial register values reset exception handling loads the cpu's program counter (pc) from the vector table, clears the trace bit in exr to 0, and sets the interrupt mask bits in ccr and exr to 1. the other ccr bits and the general registers are not initialized. in particular, the stack pointer (er7) is not initialized. the stack pointer should therefore be initialized by an mov.l instruction executed immediately after a reset.
40 2.5 data formats the cpu can process 1-bit, 4-bit (bcd), 8-bit (byte), 16-bit (word), and 32-bit (longword) data. bit-manipulation instructions operate on 1-bit data by accessing bit n (n = 0, 1, 2, , 7) of byte operand data. the daa and das decimal-adjust instructions treat byte data as two digits of 4- bit bcd data. 2.5.1 general register data formats figure 2.10 shows the data formats in general registers. 76543210 don? care 70 don? care 76543210 43 70 70 don? care upper digit lower digit lsb msb lsb data type general register data format 1-bit data 1-bit data 4-bit bcd data 4-bit bcd data byte data byte data rnh rnl rnh rnl rnh rnl msb don? care upper digit lower digit 43 70 don? care 70 don? care 70 figure 2.10 general register data formats
41 0 msb lsb 15 word data word data rn en 0 lsb 15 16 msb 31 en rn general register er general register e general register r general register rh general register rl most significant bit least significant bit legend: ern: en: rn: rnh: rnl: msb: lsb: 0 msb lsb 15 longword data ern data type general register data format figure 2.10 general register data formats (cont)
42 2.5.2 memory data formats figure 2.11 shows the data formats in memory. the cpu can access word data and longword data in memory, but word or longword data must begin at an even address. if an attempt is made to access word or longword data at an odd address, no address error occurs but the least significant bit of the address is regarded as 0, so the access starts at the preceding address. this also applies to instruction fetches. 76543210 70 msb lsb msb lsb msb lsb data type data format 1-bit data byte data word data longword data address address l address l address 2m address 2m + 1 address 2n address 2n + 1 address 2n + 2 address 2n + 3 figure 2.11 memory data formats when er7 (sp) is used as an address register to access the stack, the operand size should be word size or longword size.
43 2.6 instruction set 2.6.1 overview the h8s/2000 cpu has 65 types of instructions. the instructions are classified by function in table 2.1. table 2.1 instruction classification function instructions size types data transfer mov bwl 5 pop * 1 , push * 1 wl ldm, stm l movfpe * 3 , movtpe * 3 b arithmetic add, sub, cmp, eg bwl 19 operations addx, subx, daa, das b inc, dec bwl adds, subs l mulxu, divxu, mulxs, divxs bw extu, exts wl tas b logic operations and, or, xor, not bwl 4 shift shal, shar, shll, shlr, rotl, rotr, rotxl, rotxr bwl 8 bit manipulation bset, bclr, bnot, btst, bld, bild, bst, bist, band, biand, bor, bior, bxor, bixor b14 branch bcc * 2 , jmp, bsr, jsr, rts 5 system control trapa, rte, sleep, ldc, stc, andc, orc, xorc, nop 9 block data transfer eepmov 1 total: 65 types notes: b: byte size; w: word size; l: longword size. 1. pop.w rn and push.w rn are identical to mov.w @sp+, rn and mov.w rn, @-sp. pop.l ern and push.l ern are identical to mov.l @sp+, ern and mov.l ern, @-sp. 2. bcc is the general name for conditional branch instructions. 3. cannot be used in the h8s/2148 series or h8s/2144 series.
44 2.6.2 instructions and addressing modes table 2.2 indicates the combinations of instructions and addressing modes that the h8s/2000 cpu can use. table 2.2 combinations of instructions and addressing modes addressing modes function instruction #xx rn @ern @(d:16,ern) @(d:32,ern) @?rn/@ern+ @aa:8 @aa:16 @aa:24 @aa:32 @(d:8,pc) @(d:16,pc) @@aa:8 data mov bwl bwl bwl bwl bwl bwl b bwl bwl transfer pop, push wl ldm, stm l movfpe * , movtpe * b arithmetic add, cmp bwl bwl operations sub wlbwl addx, subx b b adds, subs l inc, dec bwl daa, das b mulxu, divxu bw mulxs, divxs bw neg bwl extu, exts wl tas b logic operations and, or, xor bwl bwl not bwl shift bwl bit manipulation b b b b b branch bcc, bsr jmp, jsr rts note: * cannot be used in the h8s/2148 series or h8s/2144 series.
45 table 2.2 combinations of instructions and addressing modes (cont) addressing modes function instruction #xx rn @ern @(d:16,ern) @(d:32,ern) @?rn/@ern+ @aa:8 @aa:16 @aa:24 @aa:32 @(d:8,pc) @(d:16,pc) @@aa:8 system trapa control rte sleep ldc b b wwwwww stc b wwwwww andc, orc, xorc b nop block data transfer bw legend: b: byte w: word l: longword
46 2.6.3 table of instructions classified by function table 2.3 summarizes the instructions in each functional category. the notation used in table 2.3 is defined below. operation notation rd general register (destination) * rs general register (source) * rn general register * ern general register (32-bit register) (ead) destination operand (eas) source operand exr extended control register ccr condition-code register n n (negative) flag in ccr z z (zero) flag in ccr v v (overflow) flag in ccr c c (carry) flag in ccr pc program counter sp stack pointer #imm immediate data disp displacement + addition C subtraction multiplication division logical and logical or ? logical exclusive or ? move ? not (logical complement) :8/:16/:24/:32 8-, 16-, 24-, or 32-bit length note: * general registers include 8-bit registers (r0h to r7h, r0l to r7l), 16-bit registers (r0 to r7, e0 to e7), and 32-bit registers (er0 to er7).
47 table 2.3 instructions classified by function type instruction size * function data transfer mov b/w/l (eas) ? rd, rs ? (ead) moves data between two general registers or between a general register and memory, or moves immediate data to a general register. movfpe b cannot be used in the h8s/2148 series or h8s/2144 series. movtpe b cannot be used in the h8s/2148 series or h8s/2144 series. pop w/l @sp+ ? rn pops a general register from the stack. pop.w rn is identical to mov.w @sp+, rn. pop.l ern is identical to mov.l @sp+, ern. push w/l rn ? @Csp pushes a general register onto the stack. push.w rn is identical to mov.w rn, @Csp. push.l ern is identical to mov.l ern, @Csp. ldm l @sp+ ? rn (register list) pops two or more general registers from the stack. stm l rn (register list) ? @Csp pushes two or more general registers onto the stack.
48 table 2.3 instructions classified by function (cont) type instruction size * function arithmetic operations add sub b/w/l rd rs ? rd, rd #imm ? rd performs addition or subtraction on data in two general registers, or on immediate data and data in a general register. (immediate byte data cannot be subtracted from byte data in a general register. use the subx or add instruction.) addx subx b rd rs c ? rd, rd #imm c ? rd performs addition or subtraction with carry on byte data in two general registers, or on immediate data and data in a general register. inc dec b/w/l rd 1 ? rd, rd 2 ? rd increments or decrements a general register by 1 or 2. (byte operands can be incremented or decremented by 1 only.) adds subs l rd 1 ? rd, rd 2 ? rd, rd 4 ? rd adds or subtracts the value 1, 2, or 4 to or from data in a 32-bit register. daa das b rd decimal adjust ? rd decimal-adjusts an addition or subtraction result in a general register by referring to the ccr to produce 4-bit bcd data. mulxu b/w rd rs ? rd performs unsigned multiplication on data in two general registers: either 8 bits 8 bits ? 16 bits or 16 bits 16 bits ? 32 bits. mulxs b/w rd rs ? rd performs signed multiplication on data in two general registers: either 8 bits 8 bits ? 16 bits or 16 bits 16 bits ? 32 bits. divxu b/w rd rs ? rd performs unsigned division on data in two general registers: either 16 bits 8 bits ? 8-bit quotient and 8- bit remainder or 32 bits 16 bits ? 16-bit quotient and 16-bit remainder.
49 table 2.3 instructions classified by function (cont) type instruction size * function arithmetic operations divxs b/w rd rs ? rd performs signed division on data in two general registers: either 16 bits 8 bits ? 8-bit quotient and 8- bit remainder or 32 bits 16 bits ? 16-bit quotient and 16-bit remainder. cmp b/w/l rd C rs, rd C #imm compares data in a general register with data in another general register or with immediate data, and sets ccr bits according to the result. neg b/w/l 0 C rd ? rd takes the two's complement (arithmetic complement) of data in a general register. extu w/l rd (zero extension) ? rd extends the lower 8 bits of a 16-bit register to word size, or the lower 16 bits of a 32-bit register to longword size, by padding with zeros on the left. exts w/l rd (sign extension) ? rd extends the lower 8 bits of a 16-bit register to word size, or the lower 16 bits of a 32-bit register to longword size, by extending the sign bit. tas b @erd C 0, 1 ? ( of @erd) tests memory contents, and sets the most significant bit (bit 7) to 1.
50 table 2.3 instructions classified by function (cont) type instruction size * function logic operations and b/w/l rd rs ? rd, rd #imm ? rd performs a logical and operation on a general register and another general register or immediate data. or b/w/l rd rs ? rd, rd #imm ? rd performs a logical or operation on a general register and another general register or immediate data. xor b/w/l rd ? rs ? rd, rd ? #imm ? rd performs a logical exclusive or operation on a general register and another general register or immediate data. not b/w/l ? (rd) ? (rd) takes the one's complement (logical complement) of general register contents. shift operations shal shar b/w/l rd (shift) ? rd performs an arithmetic shift on general register contents. a 1-bit or 2-bit shift is possible. shll shlr b/w/l rd (shift) ? rd performs a logical shift on general register contents. a 1-bit or 2-bit shift is possible. rotl rotr b/w/l rd (rotate) ? rd rotates general register contents. 1-bit or 2-bit rotation is possible. rotxl rotxr b/w/l rd (rotate) ? rd rotates general register contents through the carry flag. 1-bit or 2-bit rotation is possible.
51 table 2.3 instructions classified by function (cont) type instruction size * function bit- manipulation instructions bset b 1 ? ( of ) sets a specified bit in a general register or memory operand to 1. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. bclr b 0 ? ( of ) clears a specified bit in a general register or memory operand to 0. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. bnot b ? ( of ) ? ( of ) inverts a specified bit in a general register or memory operand. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. btst b ? ( of ) ? z tests a specified bit in a general register or memory operand and sets or clears the z flag accordingly. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. band b c ( of ) ? c ands the carry flag with a specified bit in a general register or memory operand and stores the result in the carry flag. biand b c ? ( of ) ? c ands the carry flag with the inverse of a specified bit in a general register or memory operand and stores the result in the carry flag. the bit number is specified by 3-bit immediate data. bor b c ( of ) ? c ors the carry flag with a specified bit in a general register or memory operand and stores the result in the carry flag. bior b c ? ( of ) ? c ors the carry flag with the inverse of a specified bit in a general register or memory operand and stores the result in the carry flag. the bit number is specified by 3-bit immediate data.
52 table 2.3 instructions classified by function (cont) type instruction size * function bit- manipulation instructions bxor b c ? ( of ) ? c exclusive-ors the carry flag with a specified bit in a general register or memory operand and stores the result in the carry flag. bixor b c ? ? ( of ) ? c exclusive-ors the carry flag with the inverse of a specified bit in a general register or memory operand and stores the result in the carry flag. the bit number is specified by 3-bit immediate data. bld b ( of ) ? c transfers a specified bit in a general register or memory operand to the carry flag. bild b ? ( of ) ? c transfers the inverse of a specified bit in a general register or memory operand to the carry flag. the bit number is specified by 3-bit immediate data. bst b c ? ( of ) transfers the carry flag value to a specified bit in a general register or memory operand. bist b ? c ? ( of ) transfers the inverse of the carry flag value to a specified bit in a general register or memory operand. the bit number is specified by 3-bit immediate data.
53 table 2.3 instructions classified by function (cont) type instruction size * function branch instructions bcc branches to a specified address if a specified condition is true. the branching conditions are listed below. mnemonic description condition bra(bt) always (true) always brn(bf) never (false) never bhi high c z = 0 bls low or same c z = 1 bcc(bhs) carry clear (high or same) c = 0 bcs(blo) carry set (low) c = 1 bne not equal z = 0 beq equal z = 1 bvc overflow clear v = 0 bvs overflow set v = 1 bpl plus n = 0 bmi minus n = 1 bge greater or equal n ? v = 0 blt less than n ? v = 1 bgt greater than z (n ? v) = 0 ble less or equal z (n ? v) = 1 jmp branches unconditionally to a specified address. bsr branches to a subroutine at a specified address. jsr branches to a subroutine at a specified address. rts returns from a subroutine
54 table 2.3 instructions classified by function (cont) type instruction size * function system control trapa starts trap-instruction exception handling. instructions rte returns from an exception-handling routine. sleep causes a transition to a power-down state. ldc b/w (eas) ? ccr, (eas) ? exr moves contents of a general register or memory or immediate data to ccr or exr. although ccr and exr are 8-bit registers, word-size transfers are performed between them and memory. the upper 8 bits are valid. stc b/w ccr ? (ead), exr ? (ead) transfers ccr or exr contents to a general register or memory. although ccr and exr are 8-bit registers, word-size transfers are performed between them and memory. the upper 8 bits are valid. andc b ccr #imm ? ccr, exr #imm ? exr logically ands the ccr or exr contents with immediate data. orc b ccr #imm ? ccr, exr #imm ? exr logically ors the ccr or exr contents with immediate data. xorc b ccr ? #imm ? ccr, exr ? #imm ? exr logically exclusive-ors the ccr or exr contents with immediate data. nop pc + 2 ? pc only increments the program counter.
55 table 2.3 instructions classified by function (cont) type instruction size * function block data transfer instructions eepmov.b eepmov.w if r4l _ 0 then repeat @er5+ ? @er6+ r4lC1 ? r4l until r4l = 0 else next; if r4 _ 0 then repeat @er5+ ? @er6+ r4C1 ? r4 until r4 = 0 else next; block transfer instruction. transfers the number of data bytes specified by r4l or r4 from locations starting at the address indicated by er5 to locations starting at the address indicated by er6. after the transfer, the next instruction is executed. note: * size refers to the operand size. b: byte w: word l: longword 2.6.4 basic instruction formats the cpu instructions consist of 2-byte (1-word) units. an instruction consists of an operation field (op field), a register field (r field), an effective address extension (ea field), and a condition field (cc). operation field: indicates the function of the instruction, the addressing mode, and the operation to be carried out on the operand. the operation field always includes the first four bits of the instruction. some instructions have two operation fields. register field: specifies a general register. address registers are specified by 3 bits, data registers by 3 bits or 4 bits. some instructions have two register fields. some have no register field. effective address extension: eight, 16, or 32 bits specifying immediate data, an absolute address, or a displacement. condition field: specifies the branching condition of bcc instructions. figure 2.12 shows examples of instruction formats.
56 op op rn rm nop, rts, etc. add.b rn, rm, etc. mov.b @(d:16, rn), rm, etc. (1) operation field only (2) operation field and register fields (3) operation field, register fields, and effective address extension rn rm op ea (disp) (4) operation field, effective address extension, and condition field op cc ea (disp) bra d:16, etc figure 2.12 instruction formats (examples) 2.6.5 notes on use of bit-manipulation instructions the bset, bclr, bnot, bst, and bist instructions read a byte of data, carry out bit manipulation, then write back the byte of data. caution is therefore required when using these instructions on a register containing write-only bits, or a port. the bclr instruction can be used to clear internal i/o register flags to 0. in this case, the relevant flag need not be read beforehand if it is clear that it has been set to 1 in an interrupt handling routine, etc.
57 2.7 addressing modes and effective address calculation 2.7.1 addressing mode the cpu supports the eight addressing modes listed in table 2.4. each instruction uses a subset of these addressing modes. arithmetic and logic instructions can use the register direct and immediate modes. data transfer instructions can use all addressing modes except program- counter relative and memory indirect. bit-manipulation instructions use register direct, register indirect, or absolute addressing mode to specify an operand, and register direct (bset, bclr, bnot, and btst instructions) or immediate (3-bit) addressing mode to specify a bit number in the operand. table 2.4 addressing modes no. addressing mode symbol 1 register direct rn 2 register indirect @ern 3 register indirect with displacement @(d:16,ern)/@(d:32,ern) 4 register indirect with post-increment register indirect with pre-decrement @ern+ @Cern 5 absolute address @aa:8/@aa:16/@aa:24/@aa:32 6 immediate #xx:8/#xx:16/#xx:32 7 program-counter relative @(d:8,pc)/@(d:16,pc) 8 memory indirect @@aa:8 register directrn: the register field of the instruction code specifies an 8-, 16-, or 32-bit general register containing the operand. r0h to r7h and r0l to r7l can be specified as 8-bit registers. r0 to r7 and e0 to e7 can be specified as 16-bit registers. er0 to er7 can be specified as 32-bit registers. register indirect@ern: the register field of the instruction code specifies an address register (ern) which contains the address of the operand in memory. if the address is a program instruction address, the lower 24 bits are valid and the upper 8 bits are all assumed to be 0 (h'00). register indirect with displacement@(d:16, ern) or @(d:32, ern): a 16-bit or 32-bit displacement contained in the instruction is added to an address register (ern) specified by the register field of the instruction, and the sum gives the address of a memory operand. a 16-bit displacement is sign-extended when added.
58 register indirect with post-increment or pre-decrement@ern+ or @-ern: register indirect with post-increment@ern+ the register field of the instruction code specifies an address register (ern) which contains the address of a memory operand. after the operand is accessed, 1, 2, or 4 is added to the address register contents and the sum is stored in the address register. the value added is 1 for byte access, 2 for word access, or 4 for longword access. for word or longword access, the register value should be even. register indirect with pre-decrement@-ern the value 1, 2, or 4 is subtracted from an address register (ern) specified by the register field in the instruction code, and the result becomes the address of a memory operand. the result is also stored in the address register. the value subtracted is 1 for byte access, 2 for word access, or 4 for longword access. for word or longword access, the register value should be even. absolute address@aa:8, @aa:16, @aa:24, or @aa:32: the instruction code contains the absolute address of a memory operand. the absolute address may be 8 bits long (@aa:8), 16 bits long (@aa:16), 24 bits long (@aa:24), or 32 bits long (@aa:32). to access data, the absolute address should be 8 bits (@aa:8), 16 bits (@aa:16), or 32 bits (@aa:32) long. for an 8-bit absolute address, the upper 24 bits are all assumed to be 1 (h'ffff). for a 16-bit absolute address the upper 16 bits are a sign extension. a 32-bit absolute address can access the entire address space. a 24-bit absolute address (@aa:24) indicates the address of a program instruction. the upper 8 bits are all assumed to be 0 (h'00). table 2.5 indicates the accessible absolute address ranges. table 2.5 absolute address access ranges absolute address normal mode advanced mode data address 8 bits (@aa:8) h'ff00 to h'ffff h'ffff00 to h'ffffff 16 bits (@aa:16) h'0000 to h'ffff h'000000 to h'007fff, h'ff8000 to h'ffffff 32 bits (@aa:32) h'000000 to h'ffffff program instruction address 24 bits (@aa:24)
59 immediate#xx:8, #xx:16, or #xx:32: the instruction contains 8-bit (#xx:8), 16-bit (#xx:16), or 32-bit (#xx:32) immediate data as an operand. the adds, subs, inc, and dec instructions contain immediate data implicitly. some bit manipulation instructions contain 3-bit immediate data in the instruction code, specifying a bit number. the trapa instruction contains 2-bit immediate data in its instruction code, specifying a vector address. program-counter relative@(d:8, pc) or @(d:16, pc): this mode is used in the bcc and bsr instructions. an 8-bit or 16-bit displacement contained in the instruction is sign-extended and added to the 24-bit pc contents to generate a branch address. only the lower 24 bits of this branch address are valid; the upper 8 bits are all assumed to be 0 (h'00). the pc value to which the displacement is added is the address of the first byte of the next instruction, so the possible branching range is C126 to +128 bytes (C63 to +64 words) or C32766 to +32768 bytes (C16383 to +16384 words) from the branch instruction. the resulting value should be an even number.
60 memory indirect@@aa:8: this mode can be used by the jmp and jsr instructions. the instruction code contains an 8-bit absolute address specifying a memory operand. this memory operand contains a branch address. the upper bits of the absolute address are all assumed to be 0, so the address range is 0 to 255 (h'0000 to h'00ff in normal mode, h'000000 to h'0000ff in advanced mode). in normal mode the memory operand is a word operand and the branch address is 16 bits long. in advanced mode the memory operand is a longword operand, the first byte of which is assumed to be all 0 (h'00). note that the first part of the address range is also the exception vector area. for further details, refer to section 4, exception handling. (a) normal mode (b) advanced mode branch address specified by @aa:8 specified by @aa:8 reserved branch address figure 2.13 branch address specification in memory indirect mode if an odd address is specified in word or longword memory access, or as a branch address, the least significant bit is regarded as 0, causing data to be accessed or an instruction code to be fetched at the address preceding the specified address. (for further information, see section 2.5.2, memory data formats.)
61 2.7.2 effective address calculation table 2.6 indicates how effective addresses are calculated in each addressing mode. in normal mode the upper 8 bits of the effective address are ignored in order to generate a 16-bit address. table 2.6 effective address calculation no. addressing mode and instruction format effective address calculation effective address (ea) 1 register direct (rn) op rm rn operand is general register contents. 2 register indirect (@ern) general register contents 31 0 31 0 r op 24 23 don? care 3 register indirect with displacement @(d:16, ern) or @(d:32, ern) general register contents sign extension disp 31 0 31 0 31 0 op r disp don? care 24 23 4 register indirect with post-increment or pre-decrement register indirect with post-increment @ern+ general register contents 1, 2, or 4 31 0 31 0 r op don? care 24 23 register indirect with pre-decrement @Cern general register contents 1, 2, or 4 byte word longword 1 2 4 operand size value added 31 0 31 0 op r don? care 24 23
62 table 2.6 effective address calculation (cont) no. addressing mode and instruction format effective address calculation effective address (ea) 5 absolute address @aa:8 @aa:16 @aa:32 31 0 8 7 @aa:24 31 0 16 15 31 0 31 0 op abs op abs abs op op abs h'ffff 24 23 don? care don? care don? care don? care 24 23 24 23 24 23 sign exten- sion 6 immediate #xx:8/#xx:16/#xx:32 op imm operand is immediate data. 7 program-counter relative @(d:8, pc)/@(d:16, pc) 0 0 23 23 disp 31 0 24 23 op disp pc contents don? care sign exten- sion
63 table 2.6 effective address calculation (cont) no. addressing mode and instruction format effective address calculation effective address (ea) 8 memory indirect @@aa:8 normal mode 0 0 31 8 7 0 15 h'000000 31 0 16 15 op abs abs memory contents h'00 24 23 don? care advanced mode 31 0 31 8 7 0 abs h'000000 31 0 24 23 op abs memory contents don? care
64 2.8 processing states 2.8.1 overview the cpu has five main processing states: the reset state, exception-handling state, program execution state, bus-released state, and power-down state. figure 2.14 shows a diagram of the processing states. figure 2.15 indicates the state transitions. reset state the cpu and all on-chip supporting modules have been initialized and are stopped. exception-handling state a transient state in which the cpu changes the normal processing flow in response to a reset, interrupt, or trap instruction. program execution state the cpu executes program instructions in sequence. bus-released state the external bus has been released in response to a bus request signal from a bus master other than the cpu. power-down state cpu operation is stopped to conserve power. * sleep mode software standby mode hardware standby mode processing states note: * the power-down state also includes a medium-speed mode, module stop mode, sub-active mode, sub-sleep mode, and watch mode. figure 2.14 processing states
65 end of bus request bus request program execution state bus-released state sleep mode exception-handling state external interrupt software standby mode res = high reset state stby = high, res = low hardware standby mode * 2 power-down state * 3 * 1 notes: 1. 2. 3. from any state except hardware standby mode, a transition to the reset state occurs whenever res goes low. a transition can also be made to the reset state when the watchdog timer overflows. from any state, a transition to hardware standby mode occurs when stby goes low. the power-down state also includes a watch mode, subactive mode, subsleep mode, etc. for details, refer to section 24, power-down state. sleep instruction with lson = 0, ssby = 0 interrupt request end of bus request bus request request for exception handling end of exception handling sleep instruction with lson = 0, pss = 0, ssby = 1 figure 2.15 state transitions 2.8.2 reset state when the 5(6 input goes low all current processing stops and the cpu enters the reset state. all interrupts are disabled in the reset state. reset exception handling starts when the 5(6 signal changes from low to high. the reset state can also be entered by a watchdog timer overflow. for details, refer to section 14, watchdog timer.
66 2.8.3 exception-handling state the exception-handling state is a transient state that occurs when the cpu alters the normal processing flow due to a reset, interrupt, or trap instruction. the cpu fetches a start address (vector) from the exception vector table and branches to that address. types of exception handling and their priority: exception handling is performed for resets, interrupts, and trap instructions. table 2.7 indicates the types of exception handling and their priority. trap instruction exception handling is always accepted in the program execution state. exception handling and the stack structure depend on the interrupt control mode set in syscr. table 2.7 exception handling types and priority priority type of exception detection timing start of exception handling high reset synchronized with clock exception handling starts immediately after a low-to-high transition at the 5(6 pin, or when the watchdog timer overflows. interrupt end of instruction execution or end of exception-handling sequence * 1 when an interrupt is requested, exception handling starts at the end of the current instruction or current exception-handling sequence. low trap instruction when trapa instruction is executed exception handling starts when a trap (trapa) instruction is executed. * 2 notes: 1. interrupts are not detected at the end of the andc, orc, xorc, and ldc instructions, or immediately after reset exception handling. 2. trap instruction exception handling is always accepted in the program execution state. reset exception handling: after the 5(6 pin has gone low and the reset state has been entered, when 5(6 goes high again, reset exception handling starts. when reset exception handling starts the cpu fetches a start address (vector) from the exception vector table and starts program execution from that address. all interrupts, including nmi, are disabled during reset exception handling and after it ends. interrupt exception handling and trap instruction exception handling: when interrupt or trap-instruction exception handling begins, the cpu references the stack pointer (er7) and pushes the program counter and other control registers onto the stack. next, the cpu alters the settings of the interrupt mask bits in the control registers. then the cpu fetches a start address (vector) from the exception vector table and program execution starts from that start address.
67 figure 2.16 shows the stack after exception handling ends. note: * ignored when returning. ccr pc (24 bits) sp ccr ccr * pc (16 bits) sp normal mode advanced mode figure 2.16 stack structure after exception handling (examples) 2.8.4 program execution state in this state the cpu executes program instructions in sequence. 2.8.5 bus-released state this is a state in which the bus has been released in response to a bus request from a bus master other than the cpu. while the bus is released, all cpu internal operations are halted. there is one other bus master in addition to the cpu: the data transfer controller (dtc). for further details, refer to section 6, bus controller. 2.8.6 power-down state the power-down state includes both modes in which the cpu stops operating and modes in which the cpu does not stop. there are five modes in which the cpu stops operating: sleep mode, software standby mode, hardware standby mode, subsleep mode, and watch mode. there are also three other power-down modes: medium-speed mode, module stop mode, and subactive mode. in medium-speed mode, the cpu and other bus masters operate on a medium-speed clock. module stop mode permits halting of the operation of individual modules, other than the cpu. subactive mode, subsleep mode, and watch mode are power-down modes that use subclock input. for details, refer to section 24, power-down state.
68 sleep mode: a transition to sleep mode is made if the sleep instruction is executed while the software standby bit (ssby) in the standby control register (sbycr) and the lson bit in the low-power control register (lpwrcr) are both cleared to 0. in sleep mode, cpu operations stop immediately after execution of the sleep instruction. the contents of cpu registers are retained. software standby mode: a transition to software standby mode is made if the sleep instruction is executed while the ssby bit in sbycr is set to 1 and the lson bit in lpwrcr and the pss bit in the wdt1 timer control/status register (tcsr) are both cleared to 0. in software standby mode, the cpu and clock halt and all mcu operations stop. as long as a specified voltage is supplied, the contents of cpu registers and on-chip ram are retained. the i/o ports also remain in their existing states. hardware standby mode: a transition to hardware standby mode is made when the 67%< pin goes low. in hardware standby mode, the cpu and clock halt and all mcu operations stop. the on-chip supporting modules are reset, but as long as a specified voltage is supplied, on-chip ram contents are retained. 2.9 basic timing 2.9.1 overview the cpu is driven by a system clock, denoted by the symbol ?. the period from one rising edge of ? to the next is referred to as a state. the memory cycle or bus cycle consists of one, two, or three states. different methods are used to access on-chip memory, on-chip supporting modules, and the external address space. 2.9.2 on-chip memory (rom, ram) on-chip memory is accessed in one state. the data bus is 16 bits wide, permitting both byte and word transfer instruction. figure 2.17 shows the on-chip memory access cycle. figure 2.18 shows the pin states.
69 internal address bus internal read signal internal data bus internal write signal internal data bus bus cycle t1 address read data write data read access write access figure 2.17 on-chip memory access cycle bus cycle t1 unchanged address bus as rd hwr , lwr data bus high high high high impedance figure 2.18 pin states during on-chip memory access
70 2.9.3 on-chip supporting module access timing the on-chip supporting modules are accessed in two states. the data bus is either 8 bits or 16 bits wide, depending on the particular internal i/o register being accessed. figure 2.19 shows the access timing for the on-chip supporting modules. figure 2.20 shows the pin states. bus cycle t1 t2 address read data write data internal read signal internal data bus internal write signal internal data bus read access write access internal address bus figure 2.19 on-chip supporting module access cycle
71 bus cycle t1 t2 unchanged address bus as rd hwr , lwr data bus high high high high impedance figure 2.20 pin states during on-chip supporting module access 2.9.4 external address space access timing the external address space is accessed with an 8-bit or 16-bit data bus width in a two-state or three-state bus cycle. in three-state access, wait states can be inserted. for further details, refer to section 6, bus controller.
72
73 section 3 mcu operating modes 3.1 overview 3.1.1 operating mode selection the h8s/2148 series and h8s/2144 series have three operating modes (modes 1 to 3). these modes enable selection of the cpu operating mode and enabling/disabling of on-chip rom, by setting the mode pins (md1 and md0). table 3.1 lists the mcu operating modes. table 3.1 mcu operating mode selection mcu operating mode md1 md0 cpu operating mode description on-chip rom 0 00 1 1 normal expanded mode with on-chip rom disabled disabled 2 1 0 advanced expanded mode with on-chip rom enabled single-chip mode enabled 3 1 normal expanded mode with on-chip rom enabled single-chip mode the cpus architecture allows for 4 gbytes of address space, but the h8s/2148 series and h8s/2144 series actually access a maximum of 16 mbytes. mode 1 is an externally expanded mode that allows access to external memory and peripheral devices. with modes 2 and 3, operation begins in single-chip mode after reset release, but a transition can be made to external expansion mode by setting the expe bit in mdcr. the h8s/2148 series and h8s/2144 series can only be used in modes 1 to 3. these means that the mode pins must select one of these modes. do not changes the inputs at the mode pins during operation.
74 3.1.2 register configuration the h8s/2148 series and h8s/2144 series have a mode control register (mdcr) that indicates the inputs at the mode pins (md1 and md0), a system control register (syscr) and bus control register (bcr) that control the operation of the mcu, and a serial/timer control register (stcr) that controls the operation of the supporting modules. table 3.2 summarizes these registers. table 3.2 mcu registers name abbreviation r/w initial value address * mode control register mdcr r/w undetermined h'ffc5 system control register syscr r/w h'09 h'ffc4 bus control register bcr r/w h'd7 h'ffc6 serial/timer control register stcr r/w h'00 h'ffc3 note: * lower 16 bits of the address. 3.2 register descriptions 3.2.1 mode control register (mdcr) 7 expe * r/w * 6 ? 0 5 ? 0 4 ? 0 3 ? 0 0 mds0 * r 2 ? 0 1 mds1 * r note: * determined by pins md1 and md0. bit initial value read/write mdcr is an 8-bit read-only register that indicates the operating mode setting and the current operating mode of the mcu. the expe bit is initialized in coordination with the mode pin states by a reset and in hardware standby mode.
75 bit 7expanded mode enable (expe): sets expanded mode. in mode 1, this bit is fixed at 1 and cannot be modified. in modes 2 and 3, this bit has an initial value of 0, and can be read and written. bit 7 expe description 0 single chip mode is selected 1 expanded mode is selected bits 6 to 2reserved: these bits cannot be modified and are always read as 0. bits 1 and 0mode select 1 and 0 (mds1, mds0): these bits indicate the input levels at pins md1 and md0 (the current operating mode). bits mds1 and mds0 correspond to md1 and md0. mds1 and mds0 are read-only bitsthey cannot be written to. the mode pin (md1 and md0) input levels are latched into these bits when mdcr is read. 3.2.2 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write syscr is an 8-bit readable/writable register that performs selection of system pin functions, reset source monitoring, interrupt control mode selection, nmi detected edge selection, supporting module pin location selection, supporting module register access control, and ram address space control. only bits 7, 6, 3, 1, and 0 are described here. for a detailed description of these bits, refer also to the description of the relevant modules (host interface, bus controller, watchdog timer, ram, etc.). for information on bits 5, 4, and 2, see section 5.2.1, system control register (syscr). syscr is initialized to h'09 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7chip select 2 enable (cs2e): specifies the location of the host interface control pin ( &6 ). for details, see section 18, host interface.
76 bit 6ios enable (iose): controls the function of the $6 / ,26 pin in expanded mode. bit 6 iose description 0 the $6 / ,26 pin functions as the address strobe pin (low output when accessing an external area) (initial value) 1 the $6 / ,26 pin functions as the i/o strobe pin (low output when accessing a specified address from h'(ff)f000 to h'(ff)fe4f) bit 3external reset (xrst): indicates the reset source. when the watchdog timer is used, a reset can be generated by watchdog timer overflow as well as by external reset input. xrst is a read-only bit. it is set to 1 by an external reset and cleared to 0 by watchdog timer overflow. bit 3 xrst description 0 a reset is generated by watchdog timer overflow 1 a reset is generated by an external reset (initial value) bit 1host interface enable (hie): this bit controls cpu access to the host interface data registers and control registers (hicr, idr1, odr1, str1, idr2, odr2, and str2), the keyboard controller and mos input pull-up control registers (kmimr, kmpcr, and kmimra), the 8-bit timer (channel x and y) data registers and control registers (tcrx/tcry, tcsrx/tcsry, ticrr/tcoray, ticrf/tcorby, tcntx/tcnty, tcorc/tisr, tcorax, and tcorbx), and the timer connection control registers (tconri, tconro, tconrs, and sedgr). bit 1 hie description 0 in areas h'(ff)fff0 to h'(ff)fff7 and h'(ff)fffc to h'(ff)ffff, cpu access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers, is permitted (initial value) 1 in areas h'(ff)fff0 to h'(ff)fff7 and h'(ff)fffc to h'(ff)ffff, cpu access to host interface data registers and control registers, and keyboard controller and mos input pull-up control registers, is permitted
77 bit 0ram enable (rame): enables or disables the on-chip ram. the rame bit is initialized when the reset state is released. it is not initialized in software standby mode. bit 0 rame description 0 on-chip ram is disabled 1 on-chip ram is enabled (initial value) 3.2.3 bus control register (bcr) 7 icis1 1 r/w 6 icis0 1 r/w 5 brstrm 0 r/w 4 brsts1 1 r/w 3 brsts0 0 r/w 0 ios0 1 r/w 2 ? 1 r/w 1 ios1 1 r/w bit initial value read/write bcr is an 8-bit readable/writable register that specifies the external memory space access mode, and the i/o area range when the $6 pin is designated for use as the i/o strobe. for details on bits 7 to 2, see section 6.2.1, bus control register (bcr). bcr is initialized to h'd7 by a reset and in hardware standby mode. bits 1 and 0ios select 1 and 0 (ios1, ios0): these bits specify the addresses for which the $6 / ,26 pin output goes low when iose = 1. bcr bit 1 bit 0 ios1 ios0 description 0 0 the $6 / ,26 pin output goes low in accesses to addresses h'(ff)f000 to h'(ff)f03f 1 the $6 / ,26 pin output goes low in accesses to addresses h'(ff)f000 to h'(ff)f0ff 1 0 the $6 / ,26 pin output goes low in accesses to addresses h'(ff)f000 to h'(ff)f3ff 1 the $6 / ,26 pin output goes low in accesses to addresses h'(ff)f000 to h'(ff)fe4f (initial value)
78 3.2.4 serial timer control register (stcr) 7 iics 0 r/w 6 iicx1 0 r/w 5 iicx0 0 r/w 4 iice 0 r/w 3 flshe 0 r/w 0 icks0 0 r/w 2 ? 0 r/w 1 icks1 0 r/w bit initial value read/write stcr is an 8-bit readable/writable register that controls register access, the iic operating mode (when the on-chip iic option is included), an on-chip flash memory control (in f-ztat versions), and also selects the tcnt input clock. for details of functions other than register access control, see the descriptions of the relevant modules. if a module controlled by stcr is not used, do not write 1 to the corresponding bit. stcr is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 5i 2 c control (iics, iicx1, iicx0): these bits control the operation of the i 2 c bus interface when the on-chip iic option is included. for details, see section 16, i 2 c bus interface. bit 4i 2 c master enable (iice): controls cpu access to the i 2 c bus interface data registers and control registers (iccr, icsr, icdr/sarx, and icmr/sar), the pwmx data registers and control registers (dadrah/dacr, dadral, dadrbh/dacnth, and dadrbl/dacntl), and the sci control registers (smr, brr, and scmr). bit 4 iice description 0 addresses h'(ff)ff88 and h'(ff)ff89, and h'(ff)ff8e and h'(ff)ff8f, are used for sci1 control register access addresses h'(ff)ffa0 and h'(ff)ffa1, and h'(ff)ffa6 and h'(ff)ffa7, are used for sci2 control register access addresses h'(ff)ffd8 and h'(ff)ffd9, and h'(ff)ffde and h'(ff)ffdf, are used for sci0 control register access (initial value) 1 addresses h'(ff)ff88 and h'(ff)ff89, and h'(ff)ff8e and h'(ff)ff8f, are used for iic1 data register and control register access addresses h'(ff)ffa0 and h'(ff)ffa1, and h'(ff)ffa6 and h'(ff)ffa7, are used for pwmx data register and control register access addresses h'(ff)ffd8 and h'(ff)ffd9, and h'(ff)ffde and h'(ff)ffdf, are used for iic0 data register and control register access
79 bit 3flash memory control register enable (flshe): controls cpu access to the flash memory control registers (flmcr1, flmcr2, ebr1, and ebr2), the power-down mode control registers (sbycr, lpwrcr, mstpcrh, and mstpcrl), and the supporting module control register (pcsr and syscr2). bit 3 flshe description 0 addresses h'(ff)ff80 to h'(ff)ff87 are used for power-down mode control register and supporting module control register access (initial value) 1 addresses h'(ff)ff80 to h'(ff)ff87 are used for flash memory control register access bit 2reserved: do not write 1 to this bit. bits 1 and 0internal clock select 1 and 0 (icks1, icks0): these bits, together with bits cks2 to cks0 in tcr, select the clock to be input to tcnt. for details, see section 12, 8-bit timers. 3.3 operating mode descriptions 3.3.1 mode 1 the cpu can access a 64-kbyte address space in normal mode. the on-chip rom is disabled. ports 1 and 2 function as an address bus, port 3 functions as a data bus, and part of port 9 carries bus control signals. clearing the abw bit to 0 in the wscr register makes port b a data bus. 3.3.2 mode 2 the cpu can access a 16-mbyte address space in advanced mode. the on-chip rom is enabled. after a reset, single-chip mode is set, and the expe bit in mdcr must be set to 1 in order to use external addresses. when the expe bit in mdcr is set to 1, ports 1, 2 and a function as input ports after a reset. they can be set to output addresses by setting the corresponding bits in the data direction register (ddr) to 1. port 3 functions as a data bus, and part of port 9 carries bus control signals. clearing the abw bit to 0 in the wscr register makes port b a data bus.
80 3.3.3 mode 3 the cpu can access a 64-kbyte address space in normal mode. the on-chip rom is enabled. after a reset, single-chip mode is set, and the expe bit in mdcr must be set to 1 in order to use external addresses. when the expe bit in mdcr is set to 1, ports 1 and 2 function as input ports after a reset. they can be set to output addresses by setting the corresponding bits in the data direction register (ddr) to 1. port 3 functions as a data bus, and part of port 9 carries bus control signals. clearing the abw bit to 0 in the wscr register makes port b a data bus. in this operating mode, the available amount of on-chip rom in products with 64 kbytes or more of rom is limited to 56 kbytes. 3.4 pin functions in each operating mode the pin functions of ports 1 to 3, 9, a, and b vary depending on the operating mode. table 3.3 shows their functions in each operating mode. table 3.3 pin functions in each mode port mode 1 mode 2 mode 3 port 1 a p * /a p * /a port 2 a p * /a p * /a port a p p * /a p port 3 d p * /d p * /d port b p * /d p * /d p * /d port 9 p97 p * /c p * /c p * /c p96 c * /p p * /c p * /c p95 to p93 c p * /c p * /c p92 to p91 p p p p90 p * /c p * /c p * /c legend: p: i/o port a: address bus output d: data bus i/o c: control signals, clock i/o * : after reset
81 3.5 memory map in each operating mode figures 3.1 to 3.3 show memory maps for each of the operating modes. the address space is 64 kbytes in modes 1 and 3 (normal modes), and 16 mbytes in mode 2 (advanced mode). the on-chip rom capacity is 64 kbytes (h8s/2142 and h8s/2147), 96 kbytes (h8s/2143), or 128 kbytes (h8s/2144 and h8s/2148), but only 56 kbytes are available in mode 3 (normal mode). for details, see section 6, bus controller.
82 mode 3/expe = 0 (normal single-chip mode) h'0000 h'dfff h'0000 h'dfff h'0000 external address space on-chip rom external address space on-chip rom mode 3/expe = 1 (normal expanded mode with on-chip rom enabled) mode 1 (normal expanded mode with on-chip rom disabled) h'efff h'e080 h'efff h'e080 h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 internal i/o registers 2 on-chip ram * internal i/o registers 1 h'efff on-chip ram * on-chip ram h'e080 h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 on-chip ram (128 bytes) * external address space internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) * external address space internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 note: * external addresses can be accessed by clearing the rame bit in syscr to 0. figure 3.1 h8s/2148 and h8s/2144 memory map in each operating mode
83 h'01ffff h'020000 h'000000 h'01ffff h'000000 h'ffefff h'ffe080 h'fffeff h'ffffff h'fffe50 h'ffff7f h'ffff80 h'ffff00 h'ffefff h'ffe080 h'fffeff h'fffe50 h'ffff7f h'ffff80 h'ffff00 h'ffffff mode 2/expe = 0 (advanced single-chip mode) on-chip rom external address space on-chip rom mode 2/expe = 1 (advanced expanded mode with on-chip rom enabled) internal i/o registers 2 on-chip ram * internal i/o registers 1 on-chip ram (128 bytes) * external address space internal i/o registers 2 on-chip ram internal i/o registers 1 on-chip ram (128 bytes) note: * external addresses can be accessed by clearing the rame bit in syscr to 0. figure 3.1 h8s/2148 and h8s/2144 memory map in each operating mode (cont)
84 mode 3/expe = 0 (normal single-chip mode) h'0000 h'dfff h'0000 h'dfff h'0000 external address space on-chip rom external address space on-chip rom mode 3/expe = 1 (normal expanded mode with on-chip rom enabled) mode 1 (normal expanded mode with on-chip rom disabled) h'efff h'e080 h'efff h'e080 h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 internal i/o registers 2 on-chip ram * internal i/o registers 1 h'efff on-chip ram * on-chip ram h'e080 h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 on-chip ram (128 bytes) * external address space internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) * external address space internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 note: * external addresses can be accessed by clearing the rame bit in syscr to 0. figure 3.2 h8s/2143 memory map in each operating mode
85 h'01ffff h'020000 h'000000 h'017fff h'01ffff h'000000 h'ffefff h'ffe080 h'fffeff h'ffffff h'fffe50 h'ffff7f h'ffff80 h'ffff00 h'ffefff h'ffe080 h'fffeff h'fffe50 h'ffff7f h'ffff80 h'ffff00 h'ffffff mode 2/expe = 0 (advanced single-chip mode) on-chip rom reserved area external address space mode 2/expe = 1 (advanced expanded mode with on-chip rom enabled) internal i/o registers 2 on-chip ram * internal i/o registers 1 on-chip ram (128 bytes) * external address space on-chip ram h'017fff on-chip rom reserved area internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) note: * external addresses can be accessed by clearing the rame bit in syscr to 0. figure 3.2 h8s/2143 memory map in each operating mode (cont)
86 mode 3/expe = 0 (normal single-chip mode) h'0000 h'dfff h'0000 h'dfff h'0000 external address space on-chip rom external address space mode 3/expe = 1 (normal expanded mode with on-chip rom enabled) mode 1 (normal expanded mode with on-chip rom disabled) h'efff h'e080 h'efff h'e080 h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 internal i/o registers 2 on-chip ram * reserved area * internal i/o registers 1 h'efff h'e880 on-chip ram * reserved area * h'e880 on-chip ram reserved area h'e880 h'e080 h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 on-chip ram (128 bytes) * external address space internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) * external address space on-chip rom internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 note: * external addresses can be accessed by clearing the rame bit in syscr to 0. figure 3.3 h8s/2147 and h8s/2142 memory map in each operating mode
87 h'01ffff h'020000 h'000000 h'00ffff h'01ffff h'000000 h'ffefff h'ffe080 h'ffe880 h'fffeff h'ffffff h'fffe50 h'ffff7f h'ffff80 h'ffff00 h'ffefff h'ffe080 h'fffeff h'fffe50 h'ffff7f h'ffff80 h'ffff00 h'ffffff mode 2/expe = 0 (advanced single-chip mode) on-chip rom reserved area external address space mode 2/expe = 1 (advanced expanded mode with on-chip rom enabled) internal i/o registers 2 on-chip ram * reserved area * internal i/o registers 1 on-chip ram (128 bytes) * external address space h'ffe880 on-chip ram reserved area h'00ffff on-chip rom reserved area internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) note: * external addresses can be accessed by clearing the rame bit in syscr to 0. figure 3.3 h8s/2147 and h8s/2142 memory map in each operating mode (cont)
88
89 section 4 exception handling 4.1 overview 4.1.1 exception handling types and priority as table 4.1 indicates, exception handling may be caused by a reset, trap instruction, or interrupt. exception handling is prioritized as shown in table 4.1. if two or more exceptions occur simultaneously, they are accepted and processed in order of priority. trap instruction exceptions are accepted at all times in the program execution state. exception handling sources, the stack structure, and the operation of the cpu vary depending on the interrupt control mode set by the intm0 and intm1 bits in syscr. table 4.1 exception types and priority priority exception type start of exception handling high reset starts immediately after a low-to-high transition at the 5(6 pin, or when the watchdog timer overflows. trace * 1 starts when execution of the current instruction or exception handling ends, if the trace (t) bit is set to 1. interrupt starts when execution of the current instruction or exception handling ends, if an interrupt request has been issued. * 2 direct transition started by a direct transition resulting from execution of a sleep instruction. low trap instruction (trapa) * 3 started by execution of a trap instruction (trapa). notes: 1. traces are enabled only in interrupt control modes 2 and 3. (they cannot be used in the h8s/2148 series or h8s/2144 series.) trace exception handling is not executed after execution of an rte instruction. 2. interrupt detection is not performed on completion of andc, orc, xorc, or ldc instruction execution, or on completion of reset exception handling. 3. trap instruction exception handling requests are accepted at all times in the program execution state.
90 4.1.2 exception handling operation exceptions originate from various sources. trap instructions and interrupts are handled as follows: 1. the program counter (pc) and condition-code register (ccr) are pushed onto the stack. 2. the interrupt mask bits are updated. the t bit is cleared to 0. 3. a vector address corresponding to the exception source is generated, and program execution starts from that address. for a reset exception, steps 2 and 3 above are carried out. 4.1.3 exception sources and vector table the exception sources are classified as shown in figure 4.1. different vector addresses are assigned to different exception sources. table 4.2 lists the exception sources and their vector addresses. exception sources reset trace interrupts direct transition trap instruction (cannot be used in the h8s/2148 series or h8s/2144 series) external interrupts: nmi, irq7 to irq0 internal interrupts: interrupt sources in on-chip supporting modules figure 4.1 exception sources
91 table 4.2 exception vector table vector address * 1 exception source vector number normal mode advanced mode reset 0 h'0000 to h'0001 h'0000 to h'0003 reserved for system use 1 h'0002 to h'0003 h'0004 to h'0007 2 h'0004 to h'0006 h'0008 to h'000b 3 h'0006 to h'0007 h'000c to h'000f 4 h'0008 to h'0009 h'0010 to h'0013 5 h'000a to h'000b h'0014 to h'0017 direct transition 6 h'000c to h'000d h'0018 to h'001b external interrupt nmi 7 h'000e to h'000f h'001c to h'001f trap instruction (4 sources) 8 h'0010 to h'0011 h'0020 to h'0023 9 h'0012 to h'0013 h'0024 to h'0027 10 h'0014 to h'0015 h'0028 to h'002b 11 h'0016 to h'0017 h'002c to h'002f reserved for system use 12 h'0018 to h'0019 h'0030 to h'0033 13 h'001a to h'001b h'0034 to h'0037 14 h'001c to h'001d h'0038 to h'003b 15 h'001e to h'001f h'003c to h'003f external interrupt irq0 16 h'0020 to h'0021 h'0040 to h'0043 irq1 17 h'0022 to h'0023 h'0044 to h'0047 irq2 18 h'0024 to h'0025 h'0048 to h'004b irq3 19 h'0026 to h'0027 h'004c to h'004f irq4 20 h'0028 to h'0029 h'0050 to h'0053 irq5 21 h'002a to h'002b h'0054 to h'0057 irq6 22 h'002c to h'002d h'0058 to h'005b irq7 23 h'002e to h'002f h'005c to h'005f internal interrupt * 2 24 ? 103 h'0030 to h'0031 ? h'00ce to h'00cf h'0060 to h'0063 ? h'019c to h'019f notes: 1. lower 16 bits of the address. 2. for details on internal interrupt vectors, see section 5.3.3, interrupt exception vector table.
92 4.2 reset 4.2.1 overview a reset has the highest exception priority. when the 5(6 pin goes low, all processing halts and the mcu enters the reset state. a reset initializes the internal state of the cpu and the registers of on-chip supporting modules. immediately after a reset, interrupt control mode 0 is set. reset exception handling begins when the 5(6 pin changes from low to high. h8s/2148 series and h8s/2144 series mcus can also be reset by overflow of the watchdog timer. for details, see section 14, watchdog timer. 4.2.2 reset sequence the mcu enters the reset state when the 5(6 pin goes low. to ensure that the chip is reset, hold the 5(6 pin low for at least 20 ms when powering on. to reset the chip during operation, hold the 5(6 pin low for at least 20 states. for pin states in a reset, see appendix d.1, pin states at reset. when the 5(6 pin goes high after being held low for the necessary time, the chip starts reset exception handling as follows: [1] the internal state of the cpu and the registers of the on-chip supporting modules are initialized, and the i bit is set to 1 in ccr. [2] the reset exception vector address is read and transferred to the pc, and program execution starts from the address indicated by the pc. figures 4.2 and 4.3 show examples of the reset sequence.
93 internal address bus internal read signal internal write signal internal data bus (1) (3) vector fetch internal processing fetch of first program instruction high (1) reset exception vector address ((1) = h'0000) (2) start address (contents of reset exception vector address) (3) start address ((3) = (2)) (4) first program instruction (2) (4) ? res figure 4.2 reset sequence (mode 3)
94 address bus vector fetch internal processing fetch of first program instruction (1) (3) reset exception vector address ((1) = h'0000, (3) = h'0001) (2) (4) start address (contents of reset exception vector address) (5) start address ((5) = (2) (4)) (6) first program instruction res (1) (5) high (2) (4) (3) (6) rd hwr , lwr d15 to d8 * note: * 3 program wait states are inserted. ** figure 4.3 reset sequence (mode 1) 4.2.3 interrupts after reset if an interrupt is accepted after a reset but before the stack pointer (sp) is initialized, the pc and ccr will not be saved correctly, leading to a program crash. to prevent this, all interrupt requests, including nmi, are disabled immediately after a reset. since the first instruction of a program is always executed immediately after the reset state ends, make sure that this instruction initializes the stack pointer (example: mov.l #xx:32, sp).
95 4.3 interrupts interrupt exception handling can be requested by nine external sources (nmi and irq7 to irq0) from 23 input pins (nmi, ,54 to ,54 , and .,1 to .,1 ), and internal sources in the on- chip supporting modules. figure 4.4 shows the interrupt sources and the number of interrupts of each type. the on-chip supporting modules that can request interrupts include the watchdog timer (wdt), 16-bit free-running timer (frt), 8-bit timer (tmr), serial communication interface (sci), data transfer controller (dtc), a/d converter (adc), host interface (hif), keyboard buffer controller (ps2), and i 2 c bus interface (option). each interrupt source has a separate vector address. nmi is the highest-priority interrupt. interrupts are controlled by the interrupt controller. the interrupt controller has two interrupt control modes and can assign interrupts other than nmi to either three priority/mask levels to enable multiplexed interrupt control. for details on interrupts, see section 5, interrupt controller. interrupts external interrupts internal interrupts nmi (1) irq7 to irq0 (8) wdt * (2) frt (7) tmr (10) sci (12) dtc (1) adc (1) hif (4) ps2 (3) iic (3) (option) other (1) numbers in parentheses are the numbers of interrupt sources. * when the watchdog timer is used as an interval timer, it generates an interrupt request at each counter overflow. note: figure 4.4 interrupt sources and number of interrupts
96 4.4 trap instruction trap instruction exception handling starts when a trapa instruction is executed. trap instruction exception handling can be executed at all times in the program execution state. the trapa instruction fetches a start address from a vector table entry corresponding to a vector number from 0 to 3, as specified in the instruction code. table 4.3 shows the status of ccr and exr after execution of trap instruction exception handling. table 4.3 status of ccr and exr after trap instruction exception handling ccr exr interrupt control mode i ui i2 to i0 t 01 111 legend: 1: set to 1 0: cleared to 0 : retains value prior to execution.
97 4.5 stack status after exception handling figure 4.5 shows the stack after completion of trap instruction exception handling and interrupt exception handling. sp ccr ccr * pc (16 bits) interrupt control modes 0 and 1 note: * ignored on return. figure 4.5 (1) stack status after exception handling (normal mode) sp ccr pc (24bits) interrupt control modes 0 and 1 note: * ignored on return. figure 4.5 (2) stack status after exception handling (advanced mode)
98 4.6 notes on use of the stack when accessing word data or longword data, the h8s/2148 series or h8s/2144 series chip assumes that the lowest address bit is 0. the stack should always be accessed by word transfer instruction or longword transfer instruction, and the value of the stack pointer (sp: er7) should always be kept even. use the following instructions to save registers: push.w rn (or mov.w rn, @-sp) push.l ern (or mov.l ern, @-sp) use the following instructions to restore registers: pop.w rn (or mov.w @sp+, rn) pop.l ern (or mov.l @sp+, ern) setting sp to an odd value may lead to a malfunction. figure 4.6 shows an example of what happens when the sp value is odd. sp legend: ccr: condition-code register pc: program counter r1l: general register r1l sp: stack pointer note: this diagram illustrates an example in which the interrupt control mode is 0, in advanced mode. sp sp ccr pc r1l pc h'fffefa h'fffefb h'fffefc h'fffefd h'fffeff mov.b r1l, @?r7 sp set to h'fffeff trap instruction executed data saved above sp contents of ccr lost figure 4.6 operation when sp value is odd
99 section 5 interrupt controller 5.1 overview 5.1.1 features h8s/2148 series and h8s/2144 series mcus control interrupts by means of an interrupt controller. the interrupt controller has the following features: two interrupt control modes ? either of two interrupt control modes can be set by means of the intm1 and intm0 bits in the system control register (syscr). priorities settable with icr ? an interrupt control register (icr) is provided for setting interrupt priorities. three priority levels can be set for each module for all interrupts except nmi. independent vector addresses ? all interrupt sources are assigned independent vector addresses, making it unnecessary for the source to be identified in the interrupt handling routine. twenty-three external interrupt pins (nine external sources) ? nmi is the highest-priority interrupt, and is accepted at all times. a rising or falling edge at the nmi pin can be selected for the nmi interrupt. ? falling edge, rising edge, or both edge detection, or level sensing, at pins ,54 to ,54 can be selected for interrupts irq7 to irq0. ? the irq6 interrupt is shared by the interrupt from the ,54 pin and eight external interrupt inputs ( .,1 to .,1 ), and the irq7 interrupt is shared by the interrupt from the ,54 pin and eight external interrupt inputs ( .,1 to .,1 ). .,1 to .,1 can be masked individually by the user program. dtc control ? dtc activation is controlled by means of interrupts.
100 5.1.2 block diagram a block diagram of the interrupt controller is shown in figure 5.1. syscr nmi input irq input internal interrupt requests wovi to interrupt d intm1 intm0 nmieg nmi input unit irq input unit isr iscr ier icr interrupt controller priority determination interrupt request vector number i, ui ccr cpu irq sense control register irq enable register irq status register interrupt control register system control register legend: iscr: ier: isr: icr: syscr: figure 5.1 block diagram of interrupt controller
101 5.1.3 pin configuration table 5.1 summarizes the pins of the interrupt controller. table 5.1 interrupt controller pins name symbol i/o function nonmaskable interrupt nmi input nonmaskable external interrupt; rising or falling edge can be selected external interrupt requests 7 to 0 ,54 to ,54 input maskable external interrupts; rising, falling, or both edges, or level sensing, can be selected. key input interrupt requests 15 to 0 .,1 to .,1 input maskable external interrupts: falling edge or level sensing can be selected. 5.1.4 register configuration table 5.2 summarizes the registers of the interrupt controller. table 5.2 interrupt controller registers name abbreviation r/w initial value address * 1 system control register syscr r/w h'09 h'ffc4 irq sense control register h iscrh r/w h'00 h'feec irq sense control register l iscrl r/w h'00 h'feed irq enable register ier r/w h'00 h'ffc2 irq status register isr r/(w) * 2 h'00 h'feeb keyboard matrix interrupt mask register kmimr r/w h'bf h'fff1 * 3 keyboard matrix interrupt mask register a kmimra r/w h'ff h'fff3 * 3 interrupt control register a icra r/w h'00 h'fee8 interrupt control register b icrb r/w h'00 h'fee9 interrupt control register c icrc r/w h'00 h'feea address break control register abrkcr r/w h'00 h'fef4 break address register a bara r/w h'00 h'fef5 break address register b barb r/w h'00 h'fef6 break address register c barc r/w h'00 h'fef7 notes: 1. lower 16 bits of the address. 2. only 0 can be written, for flag clearing. 3. when setting kmimr and kmimra, the hie bit in syscr must be set to 1.
102 5.2 register descriptions 5.2.1 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write syscr is an 8-bit readable/writable register that selects the interrupt control mode, and the detected edge for nmi, among other functions. only bits 5, 4, and 2 are described here; for details on the other bits, see section 3.2.2, system control register (syscr). syscr is initialized to h'09 by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 5 and 4interrupt control mode 1 and 0 (intm1, intm0): these bits select one of four interrupt control modes for the interrupt controller. the intm1 bit must not be set to 1. bit 5 bit 4 interrupt intm1 intm0 control mode description 0 0 0 interrupts are controlled by i bit (initial value) 1 1 interrupts are controlled by i and ui bits and icr 1 0 2 cannot be used in the h8s/2148 series or h8s/2144 series 1 3 cannot be used in the h8s/2148 series or h8s/2144 series bit 2nmi edge select (nmieg): selects the input edge for the nmi pin. bit 2 nmieg description 0 interrupt request generated at falling edge of nmi input (initial value) 1 interrupt request generated at rising edge of nmi input
103 5.2.2 interrupt control registers a to c (icra to icrc) 7 icr7 0 r/w 6 icr6 0 r/w 5 icr5 0 r/w 4 icr4 0 r/w 3 icr3 0 r/w 0 icr0 0 r/w 2 icr2 0 r/w 1 icr1 0 r/w bit initial value read/write the icr registers are three 8-bit readable/writable registers that set the interrupt control level for interrupts other than nmi. the correspondence between icr settings and interrupt sources is shown in table 5.3. the icr registers are initialized to h'00 by a reset and in hardware standby mode. bit ninterrupt control level (icrn): sets the control level for the corresponding interrupt source. bit n icrn description 0 corresponding interrupt source is control level 0 (non-priority) (initial value) 1 corresponding interrupt source is control level 1 (priority) (n = 7 to 0) table 5.3 correspondence between interrupt sources and icr settings bits register 7 6 5 4 3 2 1 0 icra irq0 irq1 irq2 irq3 irq4 irq5 irq6 irq7 dtc watchdog timer 0 watchdog timer 1 icrb a/d converter free- running timer 8-bit timer channel 0 8-bit timer channel 1 8-bit timer channels x, y hif, keyboard buffer controller icrc sci channel 0 sci channel 1 sci channel 2 iic channel 0 (option) iic channel 1 (option)
104 5.2.3 irq enable register (ier) 7 irq7e 0 r/w 6 irq6e 0 r/w 5 irq5e 0 r/w 4 irq4e 0 r/w 3 irq3e 0 r/w 0 irq0e 0 r/w 2 irq2e 0 r/w 1 irq1e 0 r/w bit initial value read/write ier is an 8-bit readable/writable register that controls enabling and disabling of interrupt requests irq7 to irq0. ier is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 0irq7 to irq0 enable (irq7e to irq0e): these bits select whether irq7 to irq0 are enabled or disabled. bit n irqne description 0 irqn interrupt disabled (initial value) 1 irqn interrupt enabled (n = 7 to 0)
105 5.2.4 irq sense control registers h and l (iscrh, iscrl) iscrh 15 irq7scb 0 r/w 14 irq7sca 0 r/w 13 irq6scb 0 r/w 12 irq6sca 0 r/w 11 irq5scb 0 r/w 8 irq4sca 0 r/w 10 irq5sca 0 r/w 9 irq4scb 0 r/w bit initial value read/write iscrl 7 irq3scb 0 r/w 6 irq3sca 0 r/w 5 irq2scb 0 r/w 4 irq2sca 0 r/w 3 irq1scb 0 r/w 0 irq0sca 0 r/w 2 irq1sca 0 r/w 1 irq0scb 0 r/w bit initial value read/write iscrh and iscrl are 8-bit readable/writable registers that select rising edge, falling edge, or both edge detection, or level sensing, for the input at pins ,54 to ,54 . each of the iscr registers is initialized to h'00 by a reset and in hardware standby mode. iscrh bits 7 to 0, iscrl bits 7 to 0: irq7 sense control a and b (irq7sca, irq7scb) to irq0 sense control a and b (irq0sca, irq0scb) iscrh bits 7 to 0 iscrl bits 7 to 0 irq7scb to irq0scb irq7sca to irq0sca description 0 0 interrupt request generated at ,54 to ,54 input low level (initial value) 1 interrupt request generated at falling edge of ,54 to ,54 input 1 0 interrupt request generated at rising edge of ,54 to ,54 input 1 interrupt request generated at both falling and rising edges of ,54 to ,54 input
106 5.2.5 irq status register (isr) 7 irq7f 0 r/(w) * 6 irq6f 0 r/(w) * 5 irq5f 0 r/(w) * 4 irq4f 0 r/(w) * 3 irq3f 0 r/(w) * 0 irq0f 0 r/(w) * 2 irq2f 0 r/(w) * 1 irq1f 0 r/(w) * bit initial value read/write note: * only 0 can be written, to clear the flag. isr is an 8-bit readable/writable register that indicates the status of irq7 to irq0 interrupt requests. isr is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 0irq7 to irq0 flags (irq7f to irq0f): these bits indicate the status of irq7 to irq0 interrupt requests. bit n irqnf description 0 [clearing conditions] (initial value) cleared by reading irqnf when set to 1, then writing 0 in irqnf when interrupt exception handling is executed while low-level detection is set (irqnscb = irqnsca = 0) and ,54q input is high when irqn interrupt exception handling is executed while falling, rising, or both- edge detection is set (irqnscb = 1 or irqnsca = 1) 1 [setting conditions] when ,54q input goes low when low-level detection is set (irqnscb = irqnsca = 0) when a falling edge occurs in ,54q input while falling edge detection is set (irqnscb = 0, irqnsca = 1) when a rising edge occurs in ,54q input while rising edge detection is set (irqnscb = 1, irqnsca = 0) when a falling or rising edge occurs in ,54q input while both-edge detection is set (irqnscb = irqnsca = 1) (n = 7 to 0)
107 5.2.6 keyboard matrix interrupt mask register (kmimr) 7 kmimr7 1 r/w 6 kmimr6 0 r/w 5 kmimr5 1 r/w 4 kmimr4 1 r/w 3 kmimr3 1 r/w 0 kmimr0 1 r/w 2 kmimr2 1 r/w 1 kmimr1 1 r/w bit initial value read/write kmimr is an 8-bit readable/writable register that performs mask control for the keyboard matrix interrupt inputs (pins .,1 to .,1 ). to enable key-sense input interrupts from multiple pin inputs in keyboard matrix scanning/sensing, clear the corresponding mask bits to 0. kmimr is initialized to h'bf by a reset and in hardware standby mode. bits 7 to 0keyboard matrix interrupt mask (kmimr7 to kmimr0): these bits control key-sense input interrupt requests (kin7 to kin0). bits 7 to 0 kmimr7 to kmimr0 description 0 key-sense input interrupt requests enabled 1 key-sense input interrupt requests disabled (initial value) * note: * however, the initial value of kmimr6 is 0.
108 5.2.7 keyboard matrix interrupt mask register (kmimra) 7 kmimr15 1 r/w 6 kmimr14 1 r/w 5 kmimr13 1 r/w 4 kmimr12 1 r/w 3 kmimr11 1 r/w 0 kmimr8 1 r/w 2 kmimr10 1 r/w 1 kmimr9 1 r/w bit initial value read/write kmimra is an 8-bit readable/writable register that performs mask control for the keyboard matrix interrupt inputs (pins .,1 to .,1 ). to enable key-sense input interrupts from multiple pin inputs in keyboard matrix scanning/sensing, clear the corresponding mask bits to 0. kmimra is initialized to h'ff by a reset and in hardware standby mode. bits 7 to 0keyboard matrix interrupt mask (kmimr15 to kmimr8): these bits control key-sense input interrupt requests (kin15 to kin8). bits 7 to 0 kmimr15 to kmimr8 description 0 key-sense input interrupt requests enabled 1 key-sense input interrupt requests disabled (initial value) figure 5.2 shows the relationship between interrupts irq7 and irq6 , interrupts kin15 to kin0, and registers kmimr and kmimra.
109 irq6 internal signal irq6e edge/level selection enable/disable circuit edge/level selection enable/disable circuit irq6sc irq6 interrupt kmimr0 (initial value 1) p60/ kin0 kmimr5 (initial value 1) p65/ kin5 kmimr6 (initial value 0) p66/ kin6 / irq6 kmimr7 (initial value 1) p67/ kin7 / irq7 irq7 internal signal irq7e irq7sc irq7 interrupt kmimr8 (initial value 1) pa0/ kin8 kmimr9 (initial value 1) pa1/ kin9 kmimr15 (initial value 1) pa7/ kin15 figure 5.2 relationship between interrupts irq7 and irq6 , interrupts kin15 to kin0, and registers kmimr and kmimra if any of bits kmimr15 to kmimr8 is cleared to 0, interrupt input from the ,54 pin will be ignored. when pins .,1 to .,1 or .,1 to .,1 are used as key-sense interrupt input pins, either low-level sensing or falling-edge sensing must be designated as the interrupt sense condition for the corresponding interrupt source (irq6 or irq7).
110 5.2.8 address break control register (abrkcr) 7 cmf 0 r/w 6 ? 0 5 ? 0 4 ? 0 3 0 0 bie 0 r/w 2 0 1 0 bit initial value read/write abrkcr is an 8-bit readable/writable register that performs address break control. abrkcr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7condition match flag (cmf): this is the address break source flag, used to indicate that the address set by bar has been prefetched. when the cmf flag and bie flag are both set to 1, an address break is requested. bit 7 cmf description 0 [clearing condition] when address break interrupt exception handling is executed (initial value) 1 [setting condition] when address set by bara to barc is prefetched while bie = 1 bits 6 to 1reserved: these bits cannot be modified and are always read as 0. bit 0break interrupt enable (bie): selects address break enabling or disabling. bit 0 bie description 0 address break disabled (initial value) 1 address break enabled
111 5.2.9 break address registers a, b, c (bara, barb, barc) 7 a23 0 r/w 6 a22 0 r/w 5 a21 0 r/w 4 a20 0 r/w 3 a19 0 r/w 0 a16 0 r/w 2 a18 0 r/w 1 a17 0 r/w bit bara initial value read/write 7 a15 0 r/w 6 a14 0 r/w 5 a13 0 r/w 4 a12 0 r/w 3 a11 0 r/w 0 a8 0 r/w 2 a10 0 r/w 1 a9 0 r/w bit barb initial value read/write 7 a7 0 r/w 6 a6 0 r/w 5 a5 0 r/w 4 a4 0 r/w 3 a3 0 r/w 0 ? 0 2 a2 0 r/w 1 a1 0 r/w bit barc initial value read/write bar consists of three 8-bit readable/writable registers (bara, barb, and barc), and is used to specify the address at which an address break is to be executed. each of the bar registers is initialized to h'00 by a reset and in hardware standby mode. they are not initialized in software standby mode. bara bits 7 to 0address 23 to 16 (a23 to a16) barb bits 7 to 0address 15 to 8 (a15 to a8) barc bits 7 to 1address 7 to 1 (a7 to a1) these bits specify the address at which an address break is to be executed. bar bits a23 to a1 are compared with internal address bus lines a23 to a1, respectively. the address at which the first instruction byte is located should be specified as the break address. occurrence of the address break condition may not be recognized for other addresses. in normal mode, no comparison is made with address lines a23 to a16. barc bit 0reserved: this bit cannot be modified and is always read as 0.
112 5.3 interrupt sources interrupt sources comprise external interrupts (nmi and irq7 to irq0) and internal interrupts. 5.3.1 external interrupts there are nine external interrupt sources from 25 input pins (23 actual pins): nmi, ,54 to ,54 , and .,1 to .,1 . kin15 to kin8 share the irq7 interrupt source, and kin7 to kin0 share the irq6 interrupt source. of these, nmi, irq7, irq6 , and irq2 to irq0 can be used to restore the h8s/2148 series or h8s/2144 series chip from software standby mode. nmi interrupt: nmi is the highest-priority interrupt, and is always accepted by the cpu regardless of the interrupt control mode and the status of the cpu interrupt mask bits. the nmieg bit in syscr can be used to select whether an interrupt is requested at a rising edge or a falling edge on the nmi pin. the vector number for nmi interrupt exception handling is 7. irq7 to irq0 interrupts: interrupts irq7 to irq0 are requested by an input signal at pins ,54 to ,54 . interrupts irq7 to irq0 have the following features: using iscr, it is possible to select whether an interrupt is generated by a low level, falling edge, rising edge, or both edges, at pins ,54 to ,54 . enabling or disabling of interrupt requests irq7 to irq0 can be selected with ier. the interrupt control level can be set with icr. the status of interrupt requests irq7 to irq0 is indicated in isr. isr flags can be cleared to 0 by software. a block diagram of interrupts irq7 to irq0 is shown in figure 5.3. irqn interrupt request irqne irqnf s r q clear signal edge/level detection circuit irqnsca, irqnscb irqn input note: n: 7 to 0 figure 5.3 block diagram of interrupts irq7 to irq0
113 figure 5.4 shows the timing of irqnf setting. irqn input pin irqnf figure 5.4 timing of irqnf setting the vector numbers for irq7 to irq0 interrupt exception handling are 23 to 16. detection of irq7 to irq0 interrupts does not depend on whether the relevant pin has been set for input or output. therefore, when a pin is used as an external interrupt input pin, clear the corresponding ddr bit to 0 and do not use the pin as an i/o pin for another function. when the ,54 pin is used as the irq7 interrupt input pin, bits kmimr15 to kmimr8 must all be set to 1. if any of these bits is cleared to 0, interrupt input from the ,54 pin will be ignored. as interrupt request flags irq7f to irq0f are set when the setting condition is met, regardless of the ier setting, only the necessary flags should be referenced. interrupts kin15 to kin0: interrupts kin15 to kin0 are requested by input signals at pins .,1 to .,1 0. when any of pins .,1 to .,1 are used as key-sense inputs, the corresponding kmimr bits should be cleared to 0 to enable those key-sense input interrupts. the remaining unused key-sense input kmimr bits should be set to 1 to disable those interrupts. interrupts kin15 to kin8 correspond to the irq7 interrupt, and interrupts kin7 to kin0 correspond to the irq6 interrupt. interrupt request generation pin conditions, interrupt request enabling, interrupt control level setting, and interrupt request status indications, are all in accordance with the irq7 and irq6 interrupt settings. when pins .,1 to .,1 or .,1 to .,1 are used as key-sense interrupt input pins, either low-level sensing or falling-edge sensing must be designated as the interrupt sense condition for the corresponding interrupt source (irq6 or irq7).
114 5.3.2 internal interrupts there are 43 sources for internal interrupts from on-chip supporting modules, plus one software interrupt source (pc break). for each on-chip supporting module there are flags that indicate the interrupt request status, and enable bits that select enabling or disabling of these interrupts. if any one of these is set to 1, an interrupt request is issued to the interrupt controller. the interrupt control level can be set by means of icr. the dtc can be activated by an frt, tmr, sci, or other interrupt request. when the dtc is activated by an interrupt, the interrupt control mode and interrupt mask bits have no effect. 5.3.3 interrupt exception vector table table 5.4 shows interrupt exception handling sources, vector addresses, and interrupt priorities. for default priorities, the lower the vector number, the higher the priority. priorities among modules can be set by means of icr. the situation when two or more modules are set to the same priority, and priorities within a module, are fixed as shown in table 5.4.
115 table 5.4 interrupt sources, vector addresses, and interrupt priorities origin of vector address interrupt source interrupt source vector number normal mode advanced mode icr priority nmi external 7 h'000e h'00001c high irq0 pin 16 h'0020 h'000040 icra7 irq1 17 h'0022 h'000044 icra6 irq2 irq3 18 19 h'0024 h'0026 h'000048 h'00004c icra5 irq4 irq5 20 21 h'0028 h'002a h'000050 h'000054 icra4 irq6, kin7 to kin0 irq7, kin15 to kin8 22 23 h'002c h'002e h'000058 h'00005c icra3 swdtend (software activation interrupt end) dtc 24 h'0030 h'000060 icra2 wovi0 (interval timer) watchdog timer 0 25 h'0032 h'000064 icra1 wovi1 (interval timer) watchdog timer 1 26 h'0034 h'000068 icra0 pc break 27 h'0036 h'00006c adi (a/d conversion end) a/d 28 h'0038 h'000070 icrb7 reserved 29 to 47 h'003a to h'005e h'000074 to h'0000bc icia (input capture a) icib (input capture b) icic (input capture c) icid (input capture d) ocia (output compare a) ocib (output compare b) fovi (overflow) reserved free-running timer 48 49 50 51 52 53 54 55 h'0060 h'0062 h'0064 h'0066 h'0068 h'006a h'006c h'006e h'0000c0 h'0000c4 h'0000c8 h'0000cc h'0000d0 h'0000d4 h'0000d8 h'0000dc icrb6 reserved 56 to 63 h'0070 to h'007e h'0000e0 to h'0000fc low
116 table 5.4 interrupt sources, vector addresses, and interrupt priorities (cont) origin of vector address interrupt source interrupt source vector number normal mode advanced mode icr priority cmia0 (compare-match a) cmib0 (compare-match b) ovi0 (overflow) reserved 8-bit timer channel 0 64 65 66 67 h'0080 h'0082 h'0084 h'0086 h'000100 h'000104 h'000108 h'00010c icrb3 high cmia1 (compare-match a) cmib1 (compare-match b) ovi1 (overflow) reserved 8-bit timer channel 1 68 69 70 71 h'0088 h'008a h'008c h'008e h'000110 h'000114 h'000118 h'00011c icrb2 cmiay (compare-match a) cmiby (compare-match b) oviy (overflow) icix (input capture x) 8-bit timer channels y, x 72 73 74 75 h'0090 h'0092 h'0094 h'0096 h'000120 h'000124 h'000128 h'00012c icrb1 ibf1 (idr1 reception completed) ibf2 (idr2 reception completed) ibf3 (idr3 reception completed) ibf4 (idr4 reception completed) host interface 76 77 78 79 h'0098 h'009a h'009c h'009e h'000130 h'000134 h'000138 h'00013c icrb0 eri0 (receive error 0) rxi0 (reception completed 0) txi0 (transmit data empty 0) tei0 (transmission end 0) sci channel 0 80 81 82 83 h'00a0 h'00a2 h'00a4 h'00a6 h'000140 h'000144 h'000148 h'00014c icrc7 eri1 (receive error 1) rxi1 (reception completed 1) txi1 (transmit data empty 1) tei1 (transmission end 1) sci channel 1 84 85 86 87 h'00a8 h'00aa h'00ac h'00ae h'000150 h'000154 h'000158 h'00015c icrc6 eri2 (receive error 2) rxi2 (reception completed 2) txi2 (transmit data empty 2) tei2 (transmission end 2) sci channel 2 88 89 90 91 h'00b0 h'00b2 h'00b4 h'00b6 h'000160 h'000164 h'000168 h'00016c icrc5 iici0 (1-byte transmission/ reception completed) ddcswi (format switch) iic channel 0 (option) 92 93 h'00b8 h'00ba h'000170 h'000174 icrc4 iici1 (1-byte transmission/ reception completed) reserved iic channel 1 (option) 94 95 h'00bc h'00be h'000178 h'00017c icrc3 ps2ia (reception completed a) ps2ib (reception completed b) ps2ic (reception completed c) reserved keyboard buffer controller (ps2) 96 97 98 99 h'00c0 h'00c2 h'00c4 h'00c6 h'000180 h'000184 h'000188 h'00018c icrb0 reserved 100 to 103 h'00c8 to h'00ce h'000190 to h'00019c low
117 5.4 address breaks 5.4.1 features with the h8s/2148 series and h8s/2144 series, it is possible to identify the prefetch of a specific address by the cpu and generate an address break interrupt, using the abrkcr and bar registers. when an address break interrupt is generated, address break interrupt exception handling is executed. this function can be used to detect the beginning of execution of a bug location in the program, and branch to a correction routine. 5.4.2 block diagram a block diagram of the address break function is shown in figure 5.5. bar abrkcr comparator match signal control logic address break interrupt request internal address prefetch signal (internal signal) figure 5.5 block diagram of address break function
118 5.4.3 operation abrkcr and bar settings can be made so that an address break interrupt is generated when the cpu prefetches the address set in bar. this address break function issues an interrupt request to the interrupt controller when the address is prefetched, and the interrupt controller determines the interrupt priority. when the interrupt is accepted, interrupt exception handling is started on completion of the currently executing instruction. with an address break interrupt, interrupt mask control by the i and ui bits in the cpus ccr is ineffective. the register settings when the address break function is used are as follows. 1. set the break address in bits a23 to a1 in bar. 2. set the bie bit in abrkcr to 1 to enable address breaks. an address break will not be requested if the bie bit is cleared to 0. when the setting condition occurs, the cmf flag in abrkcr is set to 1 and an interrupt is requested. if necessary, the source should be identified in the interrupt handling routine. 5.4.4 usage notes with the address break function, the address at which the first instruction byte is located should be specified as the break address. occurrence of the address break condition may not be recognized for other addresses. in normal mode, no comparison is made with address lines a23 to a16. if a branch instruction (bcc, bsr), jump instruction (jmp, jsr), rts instruction, or rte instruction is located immediately before the address set in bar, execution of this instruction will output a prefetch signal for that address, and an address break may be requested. this can be prevented by not making a break address setting for an address immediately following one of these instructions, or by determining within the interrupt handling routine whether interrupt handling was initiated by a genuine condition occurrence. as an address break interrupt is generated by a combination of the internal prefetch signal and address, the timing of the start of interrupt exception handling depends on the content and execution cycle of the instruction at the set address and the preceding instruction. figure 5.6 shows some address timing examples.
119 address bus break request signal breakpoint nop instruction is executed at breakpoint address h'0312 and next address, h'0314; fetch from address h'0316 starts after end of exception handling. instruction fetch internal operation internal operation vector fetch stack save instruction fetch h'0310 nop execution h'0310 nop h'0312 nop h'0314 nop h'0316 nop nop execution nop execution interrupt exception handling h'0312 h'0314 h'0316 h'0318 h'0036 sp-2 sp-4 ? program area in on-chip memory, 1-state execution instruction at specified break address instruction fetch address bus break request signal breakpoint mov instruction is executed at breakpoint address h'0312, nop instruction at next address, h'0316, is not executed; fetch from address h'0316 starts after end of exception handling. internal operation internal operation vector fetch stack save instruction fetch h'0310 nop execution h'0310 nop h'0312 mov.w #xx:16,rd h'0316 nop h'0318 nop mov.w execution interrupt exception handling h'0312 h'0314 h'0316 h'0318 h'0036 sp-2 sp-4 ? program area in on-chip memory, 2-state execution instruction at specified break address address bus break request signal breakpoint nop instruction at breakpoint address h'0312 is not executed; fetch from address h'0312 starts after end of exception handling. instruction fetch internal operation internal operation vector fetch stack save h'0310 nop execution h'0310 nop h'0312 nop h'0314 nop h'0316 nop interrupt exception handling h'0312 h'0314 h'0036 sp-2 sp-4 ? program area in external memory (2-state access, 16-bit-bus access), 1-state execution instruction at specified break address instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch figure 5.6 examples of address break timing
120 5.5 interrupt operation 5.5.1 interrupt control modes and interrupt operation interrupt operations in the h8s/2148 series and h8s/2144 series differ depending on the interrupt control mode. nmi interrupts are accepted at all times except in the reset state and the hardware standby state. in the case of irq interrupts and on-chip supporting module interrupts, an enable bit is provided for each interrupt. clearing an enable bit to 0 disables the corresponding interrupt request. interrupt sources for which the enable bits are set to 1 are controlled by the interrupt controller. table 5.5 shows the interrupt control modes. the interrupt controller performs interrupt control according to the interrupt control mode set by the intm1 and intm0 bits in syscr, the priorities set in icr, and the masking state indicated by the i and ui bits in the cpus ccr. table 5.5 interrupt control modes interrupt syscr priority setting interrupt control mode intm1 intm0 register mask bits description 0 0 0 icr i interrupt mask control is performed by the i bit priority can be set with icr 1 1 icr i, ui 3-level interrupt mask control is performed by the i and ui bits priority can be set with icr
121 figure 5.7 shows a block diagram of the priority decision circuit. icr ui i default priority determination vector number interrupt acceptance control and 3-level mask control interrupt source interrupt control modes 0 and 1 figure 5.7 block diagram of interrupt control operation interrupt acceptance control and 3-level control: in interrupt control modes 0 and 1, interrupt acceptance control and 3-level mask control is performed by means of the i and ui bits in ccr, and icr (control level). table 5.6 shows the interrupts selected in each interrupt control mode. table 5.6 interrupts selected in each interrupt control mode (1) interrupt mask bits interrupt control mode i ui selected interrupts 00 * all interrupts (control level 1 has priority) 1 * nmi interrupts 10 * all interrupts (control level 1 has priority) 1 0 nmi and control level 1 interrupts 1 nmi interrupts legend: * : dont care
122 default priority determination: the priority is determined for the selected interrupt, and a vector number is generated. if the same value is set for icr, acceptance of multiple interrupts is enabled, and so only the interrupt source with the highest priority according to the preset default priorities is selected and has a vector number generated. interrupt sources with a lower priority than the accepted interrupt source are held pending. table 5.7 shows operations and control signal functions in each interrupt control mode. table 5.7 operations and control signal functions in each interrupt control mode interrupt setting interrupt acceptance control 3-level control default priority control mode intm1 intm0 i ui icr determination t (trace) 000 o im pr o 11 o im im pr o legend: o: interrupt operation control performed im: used as interrupt mask bit pr: sets priority : not used
123 5.5.2 interrupt control mode 0 enabling and disabling of irq interrupts and on-chip supporting module interrupts can be set by means of the i bit in the cpus ccr, and icr. interrupts are enabled when the i bit is cleared to 0, and disabled when set to 1. control level 1 interrupt sources have higher priority. figure 5.8 shows a flowchart of the interrupt acceptance operation in this case. 1. if an interrupt source occurs when the corresponding interrupt enable bit is set to 1, an interrupt request is sent to the interrupt controller. 2. when interrupt requests are sent to the interrupt controller, a control level 1 interrupt, according to the control level set in icr, has priority for selection, and other interrupt requests are held pending. if a number of interrupt requests with the same control level setting are generated at the same time, the interrupt request with the highest priority according to the priority system shown in table 5.4 is selected. 3. the i bit is then referenced. if the i bit is cleared to 0, the interrupt request is accepted. if the i bit is set to 1, only an nmi interrupt is accepted, and other interrupt requests are held pending. 4. when an interrupt request is accepted, interrupt exception handling starts after execution of the current instruction has been completed. 5. the pc and ccr are saved to the stack area by interrupt exception handling. the pc saved on the stack shows the address of the first instruction to be executed after returning from the interrupt handling routine. 6. next, the i bit in ccr is set to 1. this disables all interrupts except nmi. 7. a vector address is generated for the accepted interrupt, and execution of the interrupt handling routine starts at the address indicated by the contents of that vector address.
124 program execution state interrupt generated? nmi? control level 1 interrupt? irq0? irq1? ps21c? irq0? irq1? ps21c? i = 0? save pc and ccr i ? 1 read vector address branch to interrupt handling routine yes no yes yes yes no no yes no yes no yes yes no no yes yes no hold pending figure 5.8 flowchart of procedure up to interrupt acceptance in interrupt control mode 0
125 5.5.3 interrupt control mode 1 three-level masking is implemented for irq interrupts and on-chip supporting module interrupts by means of the i and ui bits in the cpus ccr, and icr. control level 0 interrupt requests are enabled when the i bit is cleared to 0, and disabled when set to 1. control level 1 interrupt requests are enabled when the i bit or ui bit is cleared to 0, and disabled when both the i bit and the ui bit are set to 1. for example, if the interrupt enable bit for an interrupt request is set to 1, and h'20, h'00, and h'00 are set in icra, icrb, and icrc, respectively, (i.e. irq2 and irq3 interrupts are set to control level 1 and other interrupts to control level 0), the situation is as follows: when i = 0, all interrupts are enabled (priority order: nmi > irq2 > irq3 > irq0 > irq1 ...) when i = 1 and ui = 0, only nmi, irq2, and irq3 interrupts are enabled when i = 1 and ui = 1, only nmi interrupts are enabled figure 5.9 shows the state transitions in these cases. only nmi interrupts enabled all interrupts enabled exception handling execution or i ? 1, ui ? 1 i ? 0 i ? 1, ui ? 0 i ? 0ui ? 0 exception handling execution or ui ? 1 only nmi, irq2, and irq3 interrupts enabled figure 5.9 example of state transitions in interrupt control mode 1
126 figure 5.10 shows a flowchart of the interrupt acceptance operation in this case. 1. if an interrupt source occurs when the corresponding interrupt enable bit is set to 1, an interrupt request is sent to the interrupt controller. 2. when interrupt requests are sent to the interrupt controller, a control level 1 interrupt, according to the control level set in icr, has priority for selection, and other interrupt requests are held pending. if a number of interrupt requests with the same control level setting are generated at the same time, the interrupt request with the highest priority according to the priority system shown in table 5.4 is selected. 3. the i bit is then referenced. if the i bit is cleared to 0, the ui bit has no effect. an interrupt request set to interrupt control level 0 is accepted when the i bit is cleared to 0. if the i bit is set to 1, only an nmi interrupt is accepted, and other interrupt requests are held pending. an interrupt request set to interrupt control level 1 has priority over an interrupt request set to interrupt control level 0, and is accepted if the i bit is cleared to 0, or if the i bit is set to 1 and the ui bit is cleared to 0. when both the i bit and the ui bit are set to 1, only an nmi interrupt is accepted, and other interrupt requests are held pending. 4. when an interrupt request is accepted, interrupt exception handling starts after execution of the current instruction has been completed. 5. the pc and ccr are saved to the stack area by interrupt exception handling. the pc saved on the stack shows the address of the first instruction to be executed after returning from the interrupt handling routine. 6. next, the i and ui bits in ccr are set to 1. this disables all interrupts except nmi. 7. a vector address is generated for the accepted interrupt, and execution of the interrupt handling routine starts at the address indicated by the contents of that vector address.
127 program execution state interrupt generated? nmi? control level 1 interrupt? irq0? irq1? ps21c? irq0? irq1? ps21c? ui = 0? save pc and ccr i ? 1, ui ? 1 read vector address branch to interrupt handling routine yes no yes yes yes no no yes no yes no yes yes no no yes yes no hold pending i = 0? i = 0 yes yes no no figure 5.10 flowchart of procedure up to interrupt acceptance in interrupt control mode 1
128 5.5.4 interrupt exception handling sequence figure 5.11 shows the interrupt exception handling sequence. the example shown is for the case where interrupt control mode 0 is set in advanced mode, and the program area and stack area are in on-chip memory. (14) (12) (10) (8) (6) (4) (2) (1) (5) (7) (9) (11) (13) interrupt handling routine instruction prefetch internal operation vector fetch stack instruction prefetch internal operation interrupt acceptance interrupt level determination wait for end of instruction interrupt request signal internal address bus internal read signal internal write signal internal data bus (3) (1) (2) (4) (3) (5) (7) instruction prefetch address (not executed. this is the contents of the saved pc, the return address.) instruction code (not executed.) instruction prefetch address (not executed.) sp-2 sp-4 saved pc and saved ccr vector address interrupt handling routine start address (vector address contents) interrupt handling routine start address ((13) = (10) (12)) first instruction of interrupt handling routine (6) (8) (9) (11) (10) (12) (13) (14) figure 5.11 interrupt exception handling
129 5.5.5 interrupt response times the h8s/2148 series and h8s/2144 series are capable of fast word access to on-chip memory, and high-speed processing can be achieved by providing the program area in on-chip rom and the stack area in on-chip ram. table 5.8 shows interrupt response timesthe interval between generation of an interrupt request and execution of the first instruction in the interrupt handling routine. the symbols used in table 5.8 are explained in table 5.9. table 5.8 interrupt response times number of states no. item normal mode advanced mode 1 interrupt priority determination * 1 33 2 number of wait states until executing instruction ends * 2 1 to 19+2s i 1 to 19+2s i 3 pc, ccr stack save 2s k 2s k 4 vector fetch s i 2s i 5 instruction fetch * 3 2s i 2s i 6 internal processing * 4 22 total (using on-chip memory) 11 to 31 12 to 32 notes: 1. two states in case of internal interrupt. 2. refers to mulxs and divxs instructions. 3. prefetch after interrupt acceptance and interrupt handling routine prefetch. 4. internal processing after interrupt acceptance and internal processing after vector fetch. table 5.9 number of states in interrupt handling routine execution object of access external device 8-bit bus 16-bit bus symbol internal memory 2-state access 3-state access 2-state access 3-state access instruction fetch s i 1 4 6+2m 2 3+m branch address read s j stack manipulation s k legend: m: number of wait states in an external device access
130 5.6 usage notes 5.6.1 contention between interrupt generation and disabling when an interrupt enable bit is cleared to 0 to disable interrupts, the disabling becomes effective after execution of the instruction. in other words, when an interrupt enable bit is cleared to 0 by an instruction such as bclr or mov, if an interrupt is generated during execution of the instruction, the interrupt concerned will still be enabled on completion of the instruction, and so interrupt exception handling for that interrupt will be executed on completion of the instruction. however, if there is an interrupt request of higher priority than that interrupt, interrupt exception handling will be executed for the higher-priority interrupt, and the lower-priority interrupt will be ignored. the same also applies when an interrupt source flag is cleared to 0. figure 5.12 shows an example in which the cmiea bit in 8-bit timer register tcr is cleared to 0. internal address bus internal write signal cmiea cmfa cmia interrupt signal tcr write cycle by cpu cmia exception handling tcr address figure 5.12 contention between interrupt generation and disabling the above contention will not occur if an enable bit or interrupt source flag is cleared to 0 while the interrupt is masked.
131 5.6.2 instructions that disable interrupts instructions that disable interrupts are ldc, andc, orc, and xorc. after any of these instructions is executed, all interrupts except nmi are disabled and the next instruction is always executed. when the i bit or ui bit is set by one of these instructions, the new value becomes valid two states after execution of the instruction ends. 5.6.3 interrupts during execution of eepmov instruction interrupt operation differs between the eepmov.b instruction and the eepmov.w instruction. with the eepmov.b instruction, an interrupt request (including nmi) issued during the transfer is not accepted until the move is completed. with the eepmov.w instruction, if an interrupt request is issued during the transfer, interrupt exception handling starts at a break in the transfer cycle. the pc value saved on the stack in this case is the address of the next instruction. therefore, if an interrupt is generated during execution of an eepmov.w instruction, the following coding should be used. l1: eepmov.w mov.w r4,r4 bne l1
132 5.7 dtc activation by interrupt 5.7.1 overview the dtc can be activated by an interrupt. in this case, the following options are available: interrupt request to cpu activation request to dtc both of the above for details of interrupt requests that can be used to activate the dtc, see section 7, data transfer controller. 5.7.2 block diagram figure 5.13 shows a block diagram of the dtc and interrupt controller. selection circuit dtcer dtvecr control logic determination of priority cpu dtc dtc activation request vector number clear signal cpu interrupt request vector number select signal interrupt request interrupt source clear signal irq interrupt on-chip supporting module clear signal interrupt controller i, ui swdte clear signal figure 5.13 interrupt control for dtc
133 5.7.3 operation the interrupt controller has three main functions in dtc control. selection of interrupt source: it is possible to select dtc activation request or cpu interrupt request with the dtce bit of dtcera to dtcere in the dtc. after a dtc data transfer, the dtce bit can be cleared to 0 and an interrupt request sent to the cpu in accordance with the specification of the disel bit of mrb in the dtc. when the dtc performs the specified number of data transfers and the transfer counter reaches 0, following the dtc data transfer the dtce bit is cleared to 0 and an interrupt request is sent to the cpu. determination of priority: the dtc activation source is selected in accordance with the default priority order, and is not affected by mask or priority levels. see section 7.3.3, dtc vector table, for the respective priorities. operation order: if the same interrupt is selected as a dtc activation source and a cpu interrupt source, the dtc data transfer is performed first, followed by cpu interrupt exception handling. table 5.10 summarizes interrupt source selection and interrupt source clearance control according to the settings of the dtce bit of dtcera to dtcere in the dtc and the disel bit of mrb in the dtc. table 5.10 interrupt source selection and clearing control settings dtc interrupt source selection/clearing control dtce disel dtc cpu 0 * d 10 d 1 d legend d : the relevant interrupt is used. interrupt source clearing is performed. (the cpu should clear the source flag in the interrupt handling routine.) : the relevant interrupt is used. the interrupt source is not cleared. : the relevant bit cannot be used. * : dont care usage note: sci, iic, and a/d converter interrupt sources are cleared when the dtc reads or writes to the prescribed register, and are not dependent upon the disel bit.
134
135 section 6 bus controller 6.1 overview the h8s/2148 series and h8s/2144 series have a built-in bus controller (bsc) that allows external address space bus specifications, such as bus width and number of access states, to be set. the bus controller also has a bus arbitration function, and controls the operation of the internal bus masters: the cpu and data transfer controller (dtc). 6.1.1 features the features of the bus controller are listed below. basic bus interface ? 2-state access or 3-state access can be selected ? program wait states can be inserted burst rom interface ? external space can be designated as rom interface space ? 1-state or 2-state burst access can be selected idle cycle insertion ? an idle cycle can be inserted when an external write cycle immediately follows an external read cycle bus arbitration function ? includes a bus arbiter that arbitrates bus mastership between the cpu and dtc
136 6.1.2 block diagram figure 6.1 shows a block diagram of the bus controller. bus controller bcr wscr wait controller bus arbiter internal control signals bus mode signal internal data bus cpu bus request signal dtc bus request signal cpu bus acknowledge signal dtc bus acknowledge signal external bus control signals wait figure 6.1 block diagram of bus controller
137 6.1.3 pin configuration table 6.1 summarizes the pins of the bus controller. table 6.1 bus controller pins name symbol i/o function address strobe $6 output strobe signal indicating that address output on address bus is enabled (when iose bit is 0) i/o select ,26 output i/o select signal (when iose bit is 1) read 5' output strobe signal indicating that external space is being read high write +:5 output strobe signal indicating that external space is being written to, and that the upper data bus (d15 to d8) is enabled low write /:5 output strobe signal indicating that external space is being written to, and that the lower data bus (d7 to d0) is enabled wait :$,7 input wait request signal when external 3-state access space is accessed 6.1.4 register configuration table 6.2 summarizes the registers of the bus controller. table 6.2 bus controller registers name abbreviation r/w initial value address * bus control register bcr r/w h'd7 h'ffc6 wait state control register wscr r/w h'33 h'ffc7 note: * lower 16 bits of the address.
138 6.2 register descriptions 6.2.1 bus control register (bcr) 7 icis1 1 r/w 6 icis0 1 r/w 5 brstrm 0 r/w 4 brsts1 1 r/w 3 brsts0 0 r/w 0 ios0 1 r/w 2 ? 1 r/w 1 ios1 1 r/w bit initial value read/write bcr is an 8-bit readable/writable register that specifies the external memory space access mode, and the extent of the i/o area when the i/o strobe function has been selected for the $6 pin. bcr is initialized to h'd7 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7idle cycle insert 1 (icis1): reserved. do not write 0 to this bit. bit 6idle cycle insert 0 (icis0): selects whether or not a one-state idle cycle is to be inserted between bus cycles when successive external read and external write cycles are performed. bit 6 icis0 description 0 idle cycle not inserted in case of successive external read and external write cycles 1 idle cycle inserted in case of successive external read and external write cycles (initial value) bit 5burst rom enable (brstrm): selects whether external space is designated as a burst rom interface space. the selection applies to the entire external space . bit 5 brstrm description 0 basic bus interface (initial value) 1 burst rom interface
139 bit 4burst cycle select 1 (brsts1): selects the number of burst cycles for the burst rom interface. bit 4 brsts1 description 0 burst cycle comprises 1 state 1 burst cycle comprises 2 states (initial value) bit 3burst cycle select 0 (brsts0): selects the number of words that can be accessed in a burst rom interface burst access. bit 3 brsts0 description 0 max. 4 words in burst access (initial value) 1 max. 8 words in burst access bit 2reserved: do not write 0 to this bit. bits 1 and 0ios select 1 and 0 (ios1, ios0): see table 6.4.
140 6.2.2 wait state control register (wscr) 7 rams 0 r/w 6 ram0 0 r/w 5 abw 1 r/w 4 ast 1 r/w 3 wms1 0 r/w 0 wc0 1 r/w 2 wms0 0 r/w 1 wc1 1 r/w bit initial value read/write wscr is an 8-bit readable/writable register that specifies the data bus width, number of access states, wait mode, and number of wait states for external memory space. the on-chip memory and internal i/o register bus width and number of access states are fixed, irrespective of the wscr settings. wscr is initialized to h'33 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7ram select (rams)/bit 6ram area setting (ram0): reserved bits. bit 5bus width control (abw): specifies whether the external memory space is 8-bit access space or 16-bit access space. bit 5 abw description 0 external memory space is designated as 16-bit access space 1 external memory space is designated as 8-bit access space (initial value) bit 4access state control (ast): specifies whether the external memory space is 2-state access space or 3-state access space, and simultaneously enables or disables wait state insertion. bit 4 ast description 0 external memory space is designated as 2-state access space wait state insertion in external memory space accesses is disabled 1 external memory space is designated as 3-state access space (initial value) wait state insertion in external memory space accesses is enabled
141 bits 3 and 2wait mode select 1 and 0 (wms1, wms0): these bits select the wait mode when external memory space is accessed while the ast bit is set to 1. bit 3 bit 2 wms1 wms0 description 0 0 program wait mode (initial value) 1 wait-disabled mode 1 0 pin wait mode 1 pin auto-wait mode bits 1 and 0wait count 1 and 0 (wc1, wc0): these bits select the number of program wait states when external memory space is accessed while the ast bit is set to 1. bit 1 bit 0 wc1 wc0 description 0 0 no program wait states are inserted 1 1 program wait state is inserted in external memory space accesses 1 0 2 program wait states are inserted in external memory space accesses 1 3 program wait states are inserted in external memory space accesses (initial value) 6.3 overview of bus control 6.3.1 bus specifications the external space bus specifications consist of three elements: bus width, number of access states, and wait mode and number of program wait states. the bus width and number of access states for on-chip memory and internal i/o registers are fixed, and are not affected by the bus controller. bus width: a bus width of 8 or 16 bits can be selected with the abw bit. number of access states: two or three access states can be selected with the ast bit. when 2-state access space is designated, wait insertion is disabled. the number of access states on the burst rom interface is determined without regard to the ast bit setting. wait mode and number of program wait states: when 3-state access space is designated by the ast bit, the wait mode and the number of program wait states to be inserted automatically is selected with wms1, wms0, wc1, and wc0. from 0 to 3 program wait states can be selected.
142 table 6.3 shows the bus specifications for each basic bus interface area. table 6.3 bus specifications for each area (basic bus interface) bus specifications (basic bus interface) abw ast wms1 wms0 wc1 wc0 bus width access states program wait states 00 16 2 0 101 16 3 0 * * 00 3 0 11 10 2 13 10 8 2 0 101 8 3 0 * * 00 3 0 11 10 2 13 note: * except when wms1 = 0 and wms0 = 1 6.3.2 advanced mode the initial state of the external space is basic bus interface, three-state access space. in rom- enabled expanded mode, the space excluding the on-chip rom, on-chip ram, and internal i/o registers is external space. the on-chip ram is enabled when the rame bit in the system control register (syscr) is set to 1; when the rame bit is cleared to 0, the on-chip ram is disabled and the corresponding space becomes external space. 6.3.3 normal mode the initial state of the external memory space is basic bus interface, three-state access space. in rom-disabled expanded mode, the space excluding the on-chip ram and internal i/o registers is external space. in rom-enabled expanded mode, the space excluding the on-chip rom, on- chip ram, and internal i/o registers is external space. the on-chip ram is enabled when the rame bit in the system control register (syscr) is set to 1; when the rame bit is cleared to 0, the on-chip ram is disabled and the corresponding space becomes external space.
143 6.3.4 i/o select signal in the h8s/2148 series and h8s/2144 series, an i/o select signal ( ,26 ) can be output, with the signal output going low when the designated external space is accessed. figure 6.2 shows an example of ,26 signal output timing. address bus ios t 1 t 2 t 3 bus cycle external address in ios set range figure 6.2 ,26 ,26 signal output timing enabling or disabling of ,26 signal output is controlled by the setting of the iose bit in syscr. in expanded mode, this pin operates as the $6 output pin after a reset, and therefore the iose bit in syscr must be set to 1 in order to use this pin as the ,26 signal output. see section 8, i/o ports, for details. the range of addresses for which the ,26 signal is output can be set with bits ios1 and ios0 in bcr. the ,26 signal address ranges are shown in table 6.4. table 6.4 ,26 ,26 signal output range settings ios1 ios0 ,26 ,26 signal output range 0 0 h'(ff)f000 to h'(ff)f03f 1 h'(ff)f000 to h'(ff)f0ff 1 0 h'(ff)f000 to h'(ff)f3ff 1 h'(ff)f000 to h'(ff)fe4f (initial value)
144 6.4 basic bus interface 6.4.1 overview the basic bus interface enables direct connection of rom, sram, and so on. the bus specifications can be selected with the abw bit, the ast bit, and the wms1, wms0, wc1, and wc0 bits (see table 6.3). 6.4.2 data size and data alignment data sizes for the cpu and other internal bus masters are byte, word, and longword. the bus controller has a data alignment function, and when accessing external space, controls whether the upper data bus (d15 to d8) or lower data bus (d7 to d0) is used according to the bus specifications for the area being accessed (8-bit access space or 16-bit access space) and the data size. 8-bit access space: figure 6.3 illustrates data alignment control for the 8-bit access space. with the 8-bit access space, the upper data bus (d15 to d8) is always used for accesses. the amount of data that can be accessed at one time is one byte: a word access is performed as two byte accesses, and a longword access, as four byte accesses. d15 d8 d7 d0 upper data bus lower data bus byte size word size 1st bus cycle 2nd bus cycle longword size 1st bus cycle 2nd bus cycle 3rd bus cycle 4th bus cycle figure 6.3 access sizes and data alignment control (8-bit access space)
145 16-bit access space: figure 6.4 illustrates data alignment control for the 16-bit access space. with the 16-bit access space, the upper data bus (d15 to d8) and lower data bus (d7 to d0) are used for accesses. the amount of data that can be accessed at one time is one byte or one word, and a longword access is executed as two word accesses. in byte access, whether the upper or lower data bus is used is determined by whether the address is even or odd. the upper data bus is used for an even address, and the lower data bus for an odd address. d15 d8 d7 d0 upper data bus byte size word size 1st bus cycle 2nd bus cycle longword size ?even address byte size ?odd address lower data bus figure 6.4 access sizes and data alignment control (16-bit access space)
146 6.4.3 valid strobes table 6.5 shows the data buses used and valid strobes for the access spaces. in a read, the 5' signal is valid without discrimination between the upper and lower halves of the data bus. in a write, the +:5 signal is valid for the upper half of the data bus, and the /:5 signal for the lower half. table 6.5 data buses used and valid strobes area access size read/ write address valid strobe upper data bus (d15 to d8) lower data bus (d7 to d0) 8-bit access byte read 5' valid port, etc. space write +:5 port, etc. 16-bit access byte read even 5' valid invalid space odd invalid valid write even +:5 valid undefined odd /:5 undefined valid word read 5' valid valid write +:5 , /:5 valid valid notes: undefined: undefined data is output. invalid: input state; input value is ignored. port, etc.: pins are used as port or on-chip supporting module input/output pins, and not as data bus pins.
147 6.4.4 basic timing 8-bit 2-state access space: figure 6.5 shows the bus timing for an 8-bit 2-state access space. when an 8-bit access space is accessed, the upper half (d15 to d8) of the data bus is used. wait states cannot be inserted. bus cycle t 1 t 2 address bus ? as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 invalid read hwr d15 to d8 valid write figure 6.5 bus timing for 8-bit 2-state access space
148 8-bit 3-state access space: figure 6.6 shows the bus timing for an 8-bit 3-state access space. when an 8-bit access space is accessed, the upper half (d15 to d8) of the data bus is used. wait states can be inserted. bus cycle t 1 t 2 address bus as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 invalid read hwr d15 to d8 valid write t 3 figure 6.6 bus timing for 8-bit 3-state access space
149 16-bit, 2-state access space: figures 6.7 to 6.9 show the bus timing for 16-bit, 2-state access space. when 16-bit access space is accessed, the upper data bus (d15 to d8) is used for even addresses and the lower data bus (d7 to d0) for odd addresses. wait states cannot be inserted. bus cycle t 1 t 2 address bus as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 invalid read hwr lwr d15 to d8 valid d7 to d0 undefined write high figure 6.7 16-bit, 2-state access space bus timing (1) (even address byte access)
150 bus cycle t 1 t 2 address bus as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 invalid d7 to d0 valid read hwr lwr d15 to d8 undefined d7 to d0 valid write high figure 6.8 16-bit, 2-state access space bus timing (2) (odd address byte access)
151 bus cycle t 1 t 2 address bus as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 valid read hwr lwr d15 to d8 valid d7 to d0 valid write figure 6.9 16-bit, 2-state access space bus timing (3) (word access)
152 16-bit, 3-state access space: figures 6.10 to 6.12 show the bus timing for 16-bit, 3-state access space. when 16-bit access space is accessed, the upper data bus (d15 to d8) is used for even addresses and the lower data bus (d7 to d0) for odd addresses. wait states can be inserted. bus cycle t 1 t 2 address bus as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 invalid read hwr lwr d15 to d8 valid d7 to d0 undefined write high t 3 figure 6.10 16-bit, 3-state access space bus timing (1) (even address byte access)
153 bus cycle t 1 t 2 address bus as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 invalid d7 to d0 valid read hwr lwr d15 to d8 undefined d7 to d0 valid write high t 3 figure 6.11 16-bit, 3-state access space bus timing (2) (odd address byte access)
154 bus cycle t 1 t 2 address bus as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 valid read hwr lwr d15 to d8 valid d7 to d0 valid write t 3 figure 6.12 16-bit, 3-state access space bus timing (3) (word access)
155 6.4.5 wait control when accessing external space, the mcu can extend the bus cycle by inserting one or more wait states (t w ). there are three ways of inserting wait states: program wait insertion, pin wait insertion using the :$,7 pin, and a combination of the two. program wait mode in program wait mode, the number of t w states specified by bits wc1 and wc0 are always inserted between the t 2 and t 3 states when external space is accessed. pin wait mode in pin wait mode, the number of t w states specified by bits wc1 and wc0 are always inserted between the t 2 and t 3 states when external space is accessed. if the :$,7 pin is low at the fall of ? in the last t 2 or t w state, another t w state is inserted. if the :$,7 pin is held low, t w states are inserted until it goes high. pin wait mode is useful for inserting four or more wait states, or for changing the number of t w states for different external devices. pin auto-wait mode in pin auto-wait mode, if the :$,7 pin is low at the fall of ? in the t 2 state, the number of t w states specified by bits wc1 and wc0 are inserted when external space is accessed. no additional t w states are inserted even if the :$,7 pin remains low. pin auto-wait mode can be used for an easy interface to low-speed memory, simply by routing the chip select signal to the :$,7 pin. figure 6.13 shows an example of wait state insertion timing.
156 by program wait t 1 address bus as (iose = 0) rd data bus read data read hwr , lwr write data write note: indicates the timing of wait pin sampling using the ?clock. wait data bus t 2 t w t w t w t 3 by wait pin figure 6.13 example of wait state insertion timing the settings after a reset are: 3-state access, insertion of 3 program wait states, and wait input disabled.
157 6.5 burst rom interface 6.5.1 overview with the h8s/2148 series and h8s/2144 series, external space area 0 can be designated as burst rom space, and burst rom interfacing can be performed. external space can be designated as burst rom space by means of the brstrm bit in bcr. consecutive burst accesses of a maximum of 4 words or 8 words can be performed for cpu instruction fetches only. one or two states can be selected for burst access. 6.5.2 basic timing the number of states in the initial cycle (full access) of the burst rom interface is in accordance with the setting of the ast bit. also, when the ast bit is set to 1, wait state insertion is possible. one or two states can be selected for the burst cycle, according to the setting of the brsts1 bit in bcr. wait states cannot be inserted. when the brsts0 bit in bcr is cleared to 0, burst access of up to 4 words is performed; when the brsts0 bit is set to 1, burst access of up to 8 words is performed. the basic access timing for burst rom space is shown in figure 6.14 (a) and (b). the timing shown in figure 6.14 (a) is for the case where the ast and brsts1 bits are both set to 1, and that in figure 6.14 (b) is for the case where both these bits are cleared to 0.
158 t 1 address bus as / ios (iose = 0) data bus t 2 t 3 t 1 t 2 t 1 full access t 2 rd burst access only lower address changed read data read data read data figure 6.14 (a) example of burst rom access timing (when ast = brsts1 = 1) t 1 address bus as / ios (iose = 0) data bus t 2 t 1 t 1 full access rd burst access only lower address changed read data read data read data figure 6.14 (b) example of burst rom access timing (when ast = brsts1 = 0)
159 6.5.3 wait control as with the basic bus interface, either program wait insertion or pin wait insertion using the :$,7 pin can be used in the initial cycle (full access) of the burst rom interface. see section 6.4.5, wait control. wait states cannot be inserted in a burst cycle. 6.6 idle cycle 6.6.1 operation when the h8s/2148 series or h8s/2144 series chip accesses external space, it can insert a 1- state idle cycle (t i ) between bus cycles when a write cycle occurs immediately after a read cycle. by inserting an idle cycle it is possible, for example, to avoid data collisions between rom, with a long output floating time, and high-speed memory, i/o interfaces, and so on. if an external write occurs after an external read while the icis0 bit in bcr is set to 1, an idle cycle is inserted at the start of the write cycle. this is enabled in advanced mode and normal mode. figure 6.15 shows an example of the operation in this case. in this example, bus cycle a is a read cycle from rom with a long output floating time, and bus cycle b is a cpu write cycle. in (a), an idle cycle is not inserted, and a collision occurs in cycle b between the read data from rom and the cpu write data. in (b), an idle cycle is inserted, and a data collision is prevented. t 1 address bus rd bus cycle a data bus t 2 t 3 t 1 t 2 bus cycle b long output floating time data collision (a) idle cycle not inserted t 1 rd t 2 t 3 t i t 1 (b) idle cycle inserted t 2 hwr , lwr hwr , lwr address bus data bus bus cycle a bus cycle b figure 6.15 example of idle cycle operation
160 6.6.2 pin states in idle cycle table 6.5 shows pin states in an idle cycle. table 6.5 pin states in idle cycle pins pin state a23 to a0, ,26 contents of next bus cycle d15 to d0 high impedance $6 high 5' high +:5 , /:5 high 6.7 bus arbitration 6.7.1 overview the h8s/2148 series and h8s/2144 series have a bus arbiter that arbitrates bus master operations. there are two bus masters, the cpu and the dtc, which perform read/write operations when they have possession of the bus. each bus master requests the bus by means of a bus request signal. the bus arbiter determines priorities at the prescribed timing, and permits use of the bus by means of a bus request acknowledge signal. the selected bus master then takes possession of the bus and begins its operation. 6.7.2 operation the bus arbiter detects the bus masters bus request signals, and if the bus is requested, sends a bus request acknowledge signal to the bus master making the request. if there are bus requests from both bus masters, the bus request acknowledge signal is sent to the one with the higher priority. when a bus master receives the bus request acknowledge signal, it takes possession of the bus until that signal is canceled. the order of priority of the bus masters is as follows: (high) dtc > cpu (low)
161 6.7.3 bus transfer timing even if a bus request is received from a bus master with a higher priority than that of the bus master that has acquired the bus and is currently operating, the bus is not necessarily transferred immediately. there are specific times at which each bus master can relinquish the bus. cpu: the cpu is the lowest-priority bus master, and if a bus request is received from the dtc, the bus arbiter transfers the bus to the dtc. the timing for transfer of the bus is as follows: the bus is transferred at a break between bus cycles. however, if a bus cycle is executed in discrete operations, as in the case of a longword-size access, the bus is not transferred between the operations. see appendix a.5, bus states during instruction execution, for timings at which the bus is not transferred. if the cpu is in sleep mode, it transfers the bus immediately. dtc: the dtc sends the bus arbiter a request for the bus when an activation request is generated. the dtc does not release the bus until it has completed a series of processing operations.
162
163 section 7 data transfer controller [h8s/2148 series] provided in the h8s/2148 series; not provided in the h8s/2144 series. 7.1 overview the h8s/2148 series includes a data transfer controller (dtc). the dtc can be activated by an interrupt or software, to transfer data. 7.1.1 features transfer possible over any number of channels ? transfer information is stored in memory ? one activation source can trigger a number of data transfers (chain transfer) wide range of transfer modes ? normal, repeat, and block transfer modes available ? incrementing, decrementing, and fixing of transfer source and destination addresses can be selected direct specification of 16-mbyte address space possible ? 24-bit transfer source and destination addresses can be specified transfer can be set in byte or word units a cpu interrupt can be requested for the interrupt that activated the dtc ? an interrupt request can be issued to the cpu after one data transfer ends ? an interrupt request can be issued to the cpu after all specified data transfers have ended activation by software is possible module stop mode can be set ? the initial setting enables dtc registers to be accessed. dtc operation is halted by setting module stop mode
164 7.1.2 block diagram figure 7.1 shows a block diagram of the dtc. the dtcs register information is stored in the on-chip ram*. a 32-bit bus connects the dtc to the on-chip ram (1 kbyte), enabling 32-bit/1-state reading and writing of the dtc register information. note: * when the dtc is used, the rame bit in syscr must be set to 1. interrupt request interrupt controller dtc internal address bus dtc activation request control logic register information mra mrb cra crb dar sar cpu interrupt request on-chip ram internal data bus legend: mra, mrb: dtc mode registers a and b cra, crb: dtc transfer count registers a and b sar: dtc source address register dar: dtc destination address register dtcera to dtcere: dtc enable registers a to e dtvecr: dtc vector register dtcera to dtcere dtvecr figure 7.1 block diagram of dtc
165 7.1.3 register configuration table 7.1 summarizes the dtc registers. table 7.1 dtc registers name abbreviation r/w initial value address * 1 dtc mode register a mra * 2 undefined * 3 dtc mode register b mrb * 2 undefined * 3 dtc source address register sar * 2 undefined * 3 dtc destination address register dar * 2 undefined * 3 dtc transfer count register a cra * 2 undefined * 3 dtc transfer count register b crb * 2 undefined * 3 dtc enable registers dtcer * 4 r/w h'00 h'feee to h'fef2 dtc vector register dtvecr * 4 r/w h'00 h'fef3 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. registers within the dtc cannot be read or written to directly. 3. allocated to on-chip ram addresses h'ec00 to h'efff as register information. they cannot be located in external memory space. when the dtc is used, do not clear the rame bit in syscr to 0. 4. the h8s/2144 series does not include an on-chip dtc, and therefore the dtcer and dtvecr register addresses should not be accessed by the cpu.
166 7.2 register descriptions 7.2.1 dtc mode register a (mra) 7 sm1 6 sm0 5 dm1 4 dm0 3 md1 0 sz 2 md0 1 dts bit initial value unde- fined read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined mra is an 8-bit register that controls the dtc operating mode. bits 7 and 6source address mode 1 and 0 (sm1, sm0): these bits specify whether sar is to be incremented, decremented, or left fixed after a data transfer. bit 7 bit 6 sm1 sm0 description 0 sar is fixed 1 0 sar is incremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 1 sar is decremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) bits 5 and 4destination address mode 1 and 0 (dm1, dm0): these bits specify whether dar is to be incremented, decremented, or left fixed after a data transfer. bit 5 bit 4 dm1 dm0 description 0 dar is fixed 1 0 dar is incremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 1 dar is decremented after a transfer (by 1 when sz = 0; by 2 when sz = 1)
167 bits 3 and 2dtc mode (md1, md0): these bits specify the dtc transfer mode. bit 3 bit 2 md1 md0 description 0 0 normal mode 1 repeat mode 1 0 block transfer mode 1 bit 1dtc transfer mode select (dts): specifies whether the source side or the destination side is set to be a repeat area or block area, in repeat mode or block transfer mode. bit 1 dts description 0 destination side is repeat area or block area 1 source side is repeat area or block area bit 0dtc data transfer size (sz): specifies the size of data to be transferred. bit 0 sz description 0 byte-size transfer 1 word-size transfer
168 7.2.2 dtc mode register b (mrb) 7 chne 6 disel 5 4 3 0 2 1 bit initial value read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined mrb is an 8-bit register that controls the dtc operating mode. bit 7dtc chain transfer enable (chne): specifies chain transfer. in chain transfer, multiple data transfers can be performed consecutively in response to a single transfer request. with data transfer for which chne is set to 1, there is no determination of the end of the specified number of transfers, clearing of the interrupt source flag, or clearing of dtcer. bit 7 chne description 0 end of dtc data transfer (activation waiting state is entered) 1 dtc chain transfer (new register information is read, then data is transferred) bit 6dtc interrupt select (disel): specifies whether interrupt requests to the cpu are disabled or enabled after a data transfer. bit 6 disel description 0 after a data transfer ends, the cpu interrupt is disabled unless the transfer counter is 0 (the dtc clears the interrupt source flag of the activating interrupt to 0) 1 after a data transfer ends, the cpu interrupt is enabled (the dtc does not clear the interrupt source flag of the activating interrupt to 0) bits 5 to 0reserved: in the h8s/2148 series these bits have no effect on dtc operation, and should always be written with 0.
169 7.2.3 dtc source address register (sar) 23 22 21 20 19 43210 bit initial value unde- fined read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined sar is a 24-bit register that designates the source address of data to be transferred by the dtc. for word-size transfer, specify an even source address. 7.2.4 dtc destination address register (dar) 23 22 21 20 19 43210 bit initial value unde- fined read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined dar is a 24-bit register that designates the destination address of data to be transferred by the dtc. for word-size transfer, specify an even destination address. 7.2.5 dtc transfer count register a (cra) 15 14 13 12 11109876543210 crah cral bit initial value unde- fined read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined cra is a 16-bit register that designates the number of times data is to be transferred by the dtc. in normal mode, the entire cra register functions as a 16-bit transfer counter (1 to 65,536). it is decremented by 1 every time data is transferred, and transfer ends when the count reaches h'0000.
170 in repeat mode or block transfer mode, cra is divided into two parts: the upper 8 bits (crah) and the lower 8 bits (cral). crah holds the number of transfers while cral functions as an 8-bit transfer counter (1 to 256). cral is decremented by 1 every time data is transferred, and the contents of crah are transferred when the count reaches h'00. this operation is repeated. 7.2.6 dtc transfer count register b (crb) 15 14 13 12 11109876543210 bit initial value unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined read/write crb is a 16-bit register that designates the number of times data is to be transferred by the dtc in block transfer mode. it functions as a 16-bit transfer counter (1 to 65,536) that is decremented by 1 every time data is transferred, and transfer ends when the count reaches h'0000. 7.2.7 dtc enable registers (dtcer) 7 dtce7 0 r/w 6 dtce6 0 r/w 5 dtce5 0 r/w 4 dtce4 0 r/w 3 dtce3 0 r/w 0 dtce0 0 r/w 2 dtce2 0 r/w 1 dtce1 0 r/w bit initial value read/write the dtc enable registers comprise five 8-bit readable/writable registers, dtcera to dtcere, with bits corresponding to the interrupt sources that can activate the dtc. these bits enable or disable dtc service for the corresponding interrupt sources. the dtc enable registers are initialized to h'00 by a reset and in hardware standby mode.
171 bit ndtc activation enable (dtcen) bit n dtcen description 0 dtc activation by interrupt is disabled (initial value) [clearing conditions] when data transfer ends with the disel bit set to 1 when the specified number of transfers end 1 dtc activation by interrupt is enabled [holding condition] when the disel bit is 0 and the specified number of transfers have not ended (n = 7 to 0) a dtce bit can be set for each interrupt source that can activate the dtc. the correspondence between interrupt sources and dtce bits is shown in table 7.4, together with the vector number generated by the interrupt controller in each case. for dtce bit setting, read/write operations must be performed using bit-manipulation instructions such as bset and bclr. for the initial setting only, however, when multiple activation sources are set at one time, it is possible to disable interrupts and write after executing a dummy read on the relevant register.
172 7.2.8 dtc vector register (dtvecr) 7 swdte 0 r/(w) * 6 dtvec6 0 r/w 5 dtvec5 0 r/w 4 dtvec4 0 r/w 3 dtvec3 0 r/w 0 dtvec0 0 r/w 2 dtvec2 0 r/w 1 dtvec1 0 r/w a value of 1 can always be written to the swdte bit, but 0 can only be written after 1 is read. bit initial value read/write note: * dtvecr is an 8-bit readable/writable register that enables or disables dtc activation by software, and sets a vector number for the software activation interrupt. dtvecr is initialized to h'00 by a reset and in hardware standby mode. bit 7dtc software activation enable (swdte): specifies enabling or disabling of dtc software activation. to clear the swdte bit by software, read swdte when set to 1, then write 0 in the bit. bit 7 swdte description 0 dtc software activation is disabled [clearing condition] when the disel bit is 0 and the specified number of transfers have not ended (initial value) 1 dtc software activation is enabled [holding conditions] when data transfer ends with the disel bit set to 1 when the specified number of transfers end during software-activated data transfer bits 6 to 0dtc software activation vectors 6 to 0 (dtvec6 to dtvec0): these bits specify a vector number for dtc software activation. the vector address is h'0400 + (vector number) << 1 (where << 1 indicates a 1-bit left shift). for example, if dtvec6 to dtvec0 = h'10, the vector address is h'0420.
173 7.2.9 module stop control register (mstpcr) 15 mstp15 0 r/w bit initial value read/write 14 mstp14 0 r/w 13 mstp13 1 r/w 12 mstp12 1 r/w 11 mstp11 1 r/w 10 mstp10 1 r/w 9 mstp9 1 r/w 8 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp14 bit in mstpcr is set to 1, the dtc operation stops at the end of the bus cycle and a transition is made to module stop mode. note that 1 cannot be written to the mstp14 bit when the dtc is being activated. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 6module stop (mstp14): specifies the dtc module stop mode. mstpcrh bit 6 mstp14 description 0 dtc module stop mode is cleared (initial value) 1 dtc module stop mode is set
174 7.3 operation 7.3.1 overview when activated, the dtc reads register information that is already stored in memory and transfers data on the basis of that register information. after the data transfer, it writes updated register information back to memory. pre-storage of register information in memory makes it possible to transfer data over any required number of channels. setting the chne bit to 1 makes it possible to perform a number of transfers with a single activation. figure 7.2 shows a flowchart of dtc operation. start read dtc vector next transfer read register information data transfer write register information clear activation flag chne = 1? end no no yes yes transfer counter = 0 or disel = 1? clear dtcer interrupt exception handling figure 7.2 flowchart of dtc operation
175 the dtc transfer mode can be normal mode, repeat mode, or block transfer mode. the 24-bit sar designates the dtc transfer source address and the 24-bit dar designates the transfer destination address. after each transfer, sar and dar are independently incremented, decremented, or left fixed. table 7.2 outlines the functions of the dtc. table 7.2 dtc functions address registers transfer mode activation source transfer source transfer destination normal mode ? one transfer request transfers one byte or one word ? memory addresses are incremented or decremented by 1 or 2 ? up to 65,536 transfers possible repeat mode ? one transfer request transfers one byte or one word ? memory addresses are incremented or decremented by 1 or 2 ? after the specified number of transfers (1 to 256), the initial state resumes and operation continues block transfer mode ? one transfer request transfers a block of the specified size ? block size is from 1 to 256 bytes or words ? up to 65,536 transfers possible ? a block area can be designated at either the source or destination irq frt ici, oci 8-bit timer cmi host interface ibf sci txi or rxi a/d converter adi iic iici software 24 bits 24 bits
176 7.3.2 activation sources the dtc operates when activated by an interrupt or by a write to dtvecr by software (software activation). an interrupt request can be directed to the cpu or dtc, as designated by the corresponding dtcer bit. the interrupt request is directed to the dtc when the corresponding bit is set to 1, and to the cpu when the bit is cleared to 0. at the end of one data transfer (or the last of the consecutive transfers in the case of chain transfer) the interrupt source or the corresponding dtcer bit is cleared. table 7.3 shows activation sources and dtcer clearing. the interrupt source flag for rxi0, for example, is the rdrf flag in sci0. table 7.3 activation sources and dtcer clearing activation source when disel bit is 0 and specified number of transfers have not ended when disel bit is 1 or specified number of transfers have ended software activation swdte bit cleared to 0 swdte bit held at 1 interrupt request sent to cpu interrupt activation corresponding dtcer bit held at 1 activation source flag cleared to 0 corresponding dtcer bit cleared to 0 activation source flag held at 1 activation source interrupt request sent to cpu figure 7.3 shows a block diagram of activation source control. for details see section 5, interrupt controller.
177 on-chip supporting module irq interrupt dtvecr selection circuit interrupt controller cpu dtc dtcer clear control select interrupt request source flag cleared clear clear request interrupt mask figure 7.3 block diagram of dtc activation source control when an interrupt has been designated a dtc activation source, existing cpu mask level and interrupt controller priorities have no effect. if there is more than one activation source at the same time, the dtc is activated in accordance with the default priorities. 7.3.3 dtc vector table figure 7.4 shows the correspondence between dtc vector addresses and register information. table 7.4 shows the correspondence between activation sources, vector addresses, and dtcer bits. when the dtc is activated by software, the vector address is obtained from: h'0400 + dtvecr[6:0] << 1 (where << 1 indicates a 1-bit left shift). for example, if dtvecr is h'10, the vector address is h'0420. the dtc reads the start address of the register information from the vector address set for each activation source, and then reads the register information from that start address. the register information can be placed at predetermined addresses in the on-chip ram. the start address of the register information should be an integral multiple of four. the configuration of the vector address is the same in both normal and advanced modes, a 2- byte unit being used in both cases. these two bytes specify the lower bits of the address in the on-chip ram.
178 table 7.4 interrupt sources, dtc vector addresses, and corresponding dtces interrupt source origin of interrupt source vector number vector address dtce * priority write to dtvecr software dtvecr h'0400 + dtvecr [6:0] << 1 high irq0 external pin 16 h'0420 dtcea7 irq1 17 h'0422 dtcea6 irq2 18 h'0424 dtcea5 irq3 19 h'0426 dtcea4 adi (a/d conversion end) a/d 28 h'0438 dtcea3 icia (frt input capture a) frt 48 h'0460 dtcea2 icib (frt input capture b) 49 h'0462 dtcea1 ocia (frt output compare a) 52 h'0468 dtcea0 ocib (frt output compare b) 54 h'046a dtceb7 cmia0 (tmr0 compare-match a) tmr0 64 h'0480 dtceb2 cmib0 (tmr0 compare-match b) 65 h'0482 dtceb1 cmia1 (tmr1 compare-match a) tmr1 68 h'0488 dtceb0 cmib1 (tmr1 compare-match b) 69 h'048a dtcec7 cmiay (tmry compare-match a) tmry 72 h'0490 dtcec6 cmiby (tmry compare-match b) 73 h'0492 dtcec5 ibf1 (idr1 reception completed) hif 76 h'0498 dtcec4 ibf2 (idr2 reception completed) 77 h'049a dtcec3 rxi0 (reception completed 0) sci channel 0 81 h'04a2 dtcec2 txi0 (transmit data empty 0) 82 h'04a4 dtcec1 rxi1 (reception completed 1) sci channel 1 85 h'04aa dtcec0 txi1 (transmit data empty 1) 86 h'04ac dtced7 rxi2 (reception completed 2) sci channel 2 89 h'04b2 dtced6 txi2 (transmit data empty 2) 90 h'04b4 dtced5 iici0 (iic0 1-byte transmission/ reception completed) iic0 (option) 92 h'04b8 dtced4 iici1 (iic1 1-byte transmission/ reception completed) iic1 (option) 94 h'04bc dtced3 low note: * dtce bits with no corresponding interrupt are reserved, and should be written with 0.
179 register information start address register information chain transfer dtc vector address figure 7.4 correspondence between dtc vector address and register information 7.3.4 location of register information in address space figure 7.5 shows how the register information should be located in the address space. locate the mra, sar, mrb, dar, cra, and crb registers, in that order, from the start address of the register information (vector address contents). in chain transfer, locate the register information in consecutive areas. locate the register information in the on-chip ram (addresses: h'ffec00 to h'ffefff). register information start address chain transfer register information for 2nd transfer in chain transfer mra sar mrb dar cra crb 4 bytes lower address cra crb register information mra 0 123 sar mrb dar figure 7.5 location of dtc register information in address space
180 7.3.5 normal mode in normal mode, one operation transfers one byte or one word of data. from 1 to 65,536 transfers can be specified. once the specified number of transfers have ended, a cpu interrupt can be requested. table 7.5 lists the register information in normal mode and figure 7.6 shows memory mapping in normal mode. table 7.5 register information in normal mode name abbreviation function dtc source address register sar transfer source address dtc destination address register dar transfer destination address dtc transfer count register a cra transfer count dtc transfer count register b crb not used transfer sar dar figure 7.6 memory mapping in normal mode
181 7.3.6 repeat mode in repeat mode, one operation transfers one byte or one word of data. from 1 to 256 transfers can be specified. once the specified number of transfers have ended, the initial address register state specified by the transfer counter and repeat area resumes and transfer is repeated. in repeat mode the transfer counter does not reach h'00, and therefore cpu interrupts cannot be requested when disel = 0. table 7.6 lists the register information in repeat mode and figure 7.7 shows memory mapping in repeat mode. table 7.6 register information in repeat mode name abbreviation function dtc source address register sar transfer source address dtc destination address register dar transfer destination address dtc transfer count register ah crah holds number of transfers dtc transfer count register al cral transfer count dtc transfer count register b crb not used transfer repeat area sar or dar dar or sar figure 7.7 memory mapping in repeat mode
182 7.3.7 block transfer mode in block transfer mode, one operation transfers one block of data. either the transfer source or the transfer destination is specified as a block area. the block size is 1 to 256. when the transfer of one block ends, the initial state of the block size counter and the address register specified in the block area is restored. the other address register is successively incremented or decremented, or left fixed. from 1 to 65,536 transfers can be specified. once the specified number of transfers have ended, a cpu interrupt is requested. table 7.7 lists the register information in block transfer mode and figure 7.8 shows memory mapping in block transfer mode. table 7.7 register information in block transfer mode name abbreviation function dtc source address register sar transfer source address dtc destination address register dar transfer destination address dtc transfer count register ah crah holds block size dtc transfer count register al cral block size count dtc transfer count register b crb transfer counter
183 transfer sar or dar dar or sar block area first block nth block ? ? figure 7.8 memory mapping in block transfer mode
184 7.3.8 chain transfer setting the chne bit to 1 enables a number of data transfers to be performed consecutively in response to a single transfer request. sar, dar, cra, crb, mra, and mrb, which define data transfers, can be set independently. figure 7.9 shows memory mapping for chain transfer. source source destination destination dtc vector address register information start address register information chne = 1 register information chne = 0 figure 7.9 memory mapping in chain transfer in the case of transfer with chne set to 1, an interrupt request to the cpu is not generated at the end of the specified number of transfers or by setting of the disel bit to 1, and the interrupt source flag for the activation source is not affected.
185 7.3.9 operation timing figures 7.10 to 7.12 show examples of dtc operation timing. dtc activation request dtc request address vector read transfer information read transfer information write data transfer read write figure 7.10 dtc operation timing (normal mode or repeat mode) read write read write data transfer transfer information write transfer information read vector read dtc activation request dtc request address figure 7.11 dtc operation timing (block transfer mode, with block size of 2)
186 read write read write address dtc activation request dtc request data transfer data transfer transfer information write transfer information write transfer information read transfer information read vector read figure 7.12 dtc operation timing (chain transfer) 7.3.10 number of dtc execution states table 7.8 lists execution phases for a single dtc data transfer, and table 7.9 shows the number of states required for each execution phase. table 7.8 dtc execution phases mode vector read i register information read/write j data read k data write l internal operation m normal 1 6 1 1 3 repeat 1 6 1 1 3 block transfer 1 6 n n 3 n: block size (initial setting of crah and cral)
187 table 7.9 number of states required for each execution phase object of access on- chip ram on- chip rom internal i/o registers external devices bus width 32 16 8 16 8 8 16 16 access states 1 12223 23 execution phase vector read s i 1 4 6+2m 2 3+m register information read/write s j 1 byte data read s k 112223+m23+m word data read s k 11424 6+2m 2 3+m byte data write s l 112223+m23+m word data write s l 11424 6+2m 2 3+m internal operation s m 111111 11 the number of execution states is calculated from the formula below. note that s means the sum of all transfers activated by one activation event (the number for which the chne bit is set to one, plus 1). number of execution states = i s i + s (j s j + k s k + l s l ) + m s m for example, when the dtc vector address table is located in on-chip rom, normal mode is set, and data is transferred from the on-chip rom to an internal i/o register, the time required for the dtc operation is 13 states. the time from activation to the end of the data write is 10 states.
188 7.3.11 procedures for using the dtc activation by interrupt: the procedure for using the dtc with interrupt activation is as follows: 1. set the mra, mrb, sar, dar, cra, and crb register information in the on-chip ram. 2. set the start address of the register information in the dtc vector address. 3. set the corresponding bit in dtcer to 1. 4. set the enable bits for the interrupt sources to be used as the activation sources to 1. the dtc is activated when an interrupt used as an activation source is generated. 5. after the end of one data transfer, or after the specified number of data transfers have ended, the dtce bit is cleared to 0 and a cpu interrupt is requested. if the dtc is to continue transferring data, set the dtce bit to 1. activation by software: the procedure for using the dtc with software activation is as follows: 1. set the mra, mrb, sar, dar, cra, and crb register information in the on-chip ram. 2. set the start address of the register information in the dtc vector address. 3. check that the swdte bit is 0. 4. write 1 in the swdte bit and the vector number to dtvecr. 5. check the vector number written to dtvecr. 6. after the end of one data transfer, if the disel bit is 0 and a cpu interrupt is not requested, the swdte bit is cleared to 0. if the dtc is to continue transferring data, set the swdte bit to 1. when the disel bit is 1, or after the specified number of data transfers have ended, the swdte bit is held at 1 and a cpu interrupt is requested.
189 7.3.12 examples of use of the dtc normal mode: an example is shown in which the dtc is used to receive 128 bytes of data via the sci. 1. set mra to fixed source address (sm1 = sm0 = 0), incrementing destination address (dm1 = 1, dm0 = 0), normal mode (md1 = md0 = 0), and byte size (sz = 0). the dts bit can have any value. set mrb for one data transfer by one interrupt (chne = 0, disel = 0). set the sci rdr address in sar, the start address of the ram area where the data will be received in dar, and 128 (h'0080) in cra. crb can be set to any value. 2. set the start address of the register information at the dtc vector address. 3. set the corresponding bit in dtcer to 1. 4. set the sci to the appropriate receive mode. set the rie bit in scr to 1 to enable the reception complete (rxi) interrupt. since the generation of a receive error during the sci reception operation will disable subsequent reception, the cpu should be enabled to accept receive error interrupts. 5. each time reception of one byte of data ends on the sci, the rdrf flag in ssr is set to 1, an rxi interrupt is generated, and the dtc is activated. the receive data is transferred from rdr to ram by the dtc. dar is incremented and cra is decremented. the rdrf flag is automatically cleared to 0. 6. when cra becomes 0 after the 128 data transfers have ended, the rdrf flag is held at 1, the dtce bit is cleared to 0, and an rxi interrupt request is sent to the cpu. the interrupt handling routine should perform wrap-up processing. software activation: an example is shown in which the dtc is used to transfer a block of 128 bytes of data by means of software activation. the transfer source address is h'1000 and the destination address is h'2000. the vector number is h'60, so the vector address is h'04c0. 1. set mra to incrementing source address (sm1 = 1, sm0 = 0), incrementing destination address (dm1 = 1, dm0 = 0), block transfer mode (md1 = 1, md0 = 0), and byte size (sz = 0). the dts bit can have any value. set mrb for one block transfer by one interrupt (chne = 0). set the transfer source address (h'1000) in sar, the destination address (h'2000) in dar, and 128 (h'8080) in cra. set 1 (h'0001) in crb. 2. set the start address of the register information at the dtc vector address (h'04c0). 3. check that the swdte bit in dtvecr is 0. check that there is currently no transfer activated by software. 4. write 1 to the swdte bit and the vector number (h'60) to dtvecr. the write data is h'e0. 5. read dtvecr again and check that it is set to the vector number (h'60). if it is not, this indicates that the write failed. this is presumably because an interrupt occurred between steps 3 and 4 and led to a different software activation. to activate this transfer, go back to step 3.
190 6. if the write was successful, the dtc is activated and a block of 128 bytes of data is transferred. 7. after the transfer, an swdtend interrupt occurs. the interrupt handling routine should clear the swdte bit to 0 and perform other wrap-up processing. 7.4 interrupts an interrupt request is issued to the cpu when the dtc finishes the specified number of data transfers, or a data transfer for which the disel bit was set to 1. in the case of interrupt activation, the interrupt set as the activation source is generated. these interrupts to the cpu are subject to cpu mask level and interrupt controller priority level control. in the case of activation by software, a software-activated data transfer end interrupt (swdtend) is generated. when the disel bit is 1 and one data transfer has ended, or the specified number of transfers have ended, after data transfer ends, the swdte bit is held at 1 and an swdtend interrupt is generated. the interrupt handling routine should clear the swdte bit to 0. when the dtc is activated by software, an swdtend interrupt is not generated during a data transfer wait or during data transfer even if the swdte bit is set to 1. 7.5 usage notes module stop: when the mstp14 bit in mstpcr is set to 1, the dtc clock stops, and the dtc enters the module stop state. however, 1 cannot be written in the mstp14 bit while the dtc is operating. when the dtc is placed in the module stop state, the dtcer registers must all be in the cleared state when the mstp14 bit is set to 1. on-chip ram: the mra, mrb, sar, dar, cra, and crb registers are all located in on- chip ram. when the dtc is used, the rame bit in syscr must not be cleared to 0. dtce bit setting: for dtce bit setting, read/write operations must be performed using bit- manipulation instructions such as bset and bclr. for the initial setting only, however, when multiple activation sources are set at one time, it is possible to disable interrupts and write after executing a dummy read on the relevant register.
191 section 8 i/o ports 8.1 overview the h8s/2148 series and h8s/2144 series have ten i/o ports (ports 1 to 6, 8, 9, a, and b), and one input-only port (port 7). tables 8.1 and 8.2 summarize the port functions. the pins of each port also have other functions. each port includes a data direction register (ddr) that controls input/output (not provided for the input-only port) and data registers (dr, odr) that store output data. ports 1 to 3, 6, a, and b have a built-in mos input pull-up function. for ports a and b, the on/off status of the mos input pull-up is controlled by ddr and odr. ports 1 to 3 and 6 have a mos input pull-up control register (pcr), in addition to ddr and dr, to control the on/off status of the mos input pull-ups. ports 1 to 6, 8, 9, a, and b can drive a single ttl load and 30 pf capacitive load. all the i/o ports can drive a darlington transistor when in output mode. ports 1, 2, and 3 can drive an led (10 ma sink current). in the h8s/2148 series, pa4 to pa7 in port a have bus buffer drive capability. p52 in port 5 and p97 in port 9 are nmos push-pull outputs. note that the h8s/2144 series has subset specifications that do not include some supporting modules. for differences in pin functions, see table 8.1, h8s/2148 series port functions, and table 8.2, h8s/2144 series port functions.
192 table 8.1 h8s/2148 series port functions expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 1 8-bit i/o port built-in mos input pull-ups led drive capability p17 to p10/ a7 to a0/ pw7 to pw0 lower address output (a7 to a0) when ddr = 0 (after reset): input port when ddr = 1: lower address output (a7 to a0) or pwm timer output (pw7 to pw0) i/o port also functioning as pwm timer output (pw7 to pw0) port 2 8-bit i/o port built-in mos input pull-ups led drive capability p27/a15/pw15/ cblank p26/a14/pw14 p25/a13/pw13 p24/a12/pw12 p23/a11/pw11 p22/a10/pw10 p21/a9/pw9 p20/a8/pw8 upper address output (a15 to a8) when ddr = 0 (after reset): input port or timer connection output (cblank) when ddr = 1: upper address output (a15 to a8), pwm timer output (pw15 to pw8), timer connection output (cblank), or output ports (p27 to p24) i/o port also functioning as pwm timer output (pw15 to pw8) and timer connection output (cblank) port 3 8-bit i/o port built-in mos input pull-ups led drive capability p37 to p30/ hdb7 to hdb0/ d15 to d8 data bus input/output (d15 to d8) i/o port also functioning as host interface data bus input/output (hdb7 to hdb0)
193 table 8.1 h8s/2148 series port functions (cont) expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 4 8-bit i/o port p47/pwx1 p46/pwx0 p45/tmri1/ hirq12/csynci p44/tmo1/ hirq1/hsynco p43/tmci1/ hirq11/hsynci p42/tmri0/ sck2/sda1 p41/tmo0/ rxd2/irrxd p40/tmci0/ txd2/irtxd i/o port also functioning as 14-bit pwm timer output (pwx1, pwx0), 8-bit timer 0 and 1 input/output (tmci0, tmri0, tmo0, tmci1, tmri1, tmo1), timer connection input/output (hsynco, csynci, hsynci), sci2 input/output (txd2, rxd2, sck2), irda interface input/output (irtxd, irrxd), and i 2 c bus interface 1 (option) input/output (sda1) i/o port also functioning as 14-bit pwm timer output (pwx1, pwx0), 8-bit timer 0 and 1 input/ output (tmci0, tmri0, tmo0, tmci1, tmri1, tmo1), timer connection input/output (hsynco, csynci, hsynci), host interface host cpu interrupt request output (hirq12, hirq1, hirq11), sci2 input/ output (txd2, rxd2, sck2), irda interface input/output (irtxd, irrxd), and i 2 c bus interface 1 (option) input/output (sda1) port 5 3-bit i/o port p52/sck0/scl0 p51/rxd0 p50/txd0 i/o port also functioning as sci0 input/output (txd0, rxd0, sck0) and i 2 c bus interface 0 (option) input/output (scl0) port 6 8-bit i/o port p67/ ,54 /tmox/ .,1 /cin7 p66/ ,54 /ftob/ .,1 /cin6 p65/ftid/ .,1 / cin5 p64/ftic/ .,1 / cin4/clampo p63/ftib/ .,1 / cin3/vfbacki p62/ftia/tmiy/ .,1 /cin2/ vsynci p61/ftoa/ .,1 /cin 1/vsynco p60/ftci/tmix/ .,1 /cin0/ hfbacki i/o port also functioning as external interrupt input ( ,54 , ,54 ), frt input/output (ftci, ftoa, ftia, ftib, ftic, ftid, ftob), 8- bit timer x and y input/output (tmox, tmix, tmiy), timer connection input/output (clampo, vfbacki, vsynci, vsynco, hfbacki), key-sense interrupt input ( .,1 to .,1 ), and expansion a/d converter input (cin7 to cin0)
194 table 8.1 h8s/2148 series port functions (cont) expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 7 8-bit input port p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 input port also functioning as a/d converter analog input (an7 to an0) and d/a converter analog output (da1, da0) port 8 7-bit i/o port p86/ ,54 /sck1/sc l1 p85/ ,54 /rxd1 p84/ ,54 /txd1 p83 p82/hifsd p81/ &6 /ga20 p80/ha0 i/o port also functioning as external interrupt input ( ,54 , ,54 , ,54 ), sci1 input/ output (txd1, rxd1, sck1), and i 2 c bus interface 1 (option) input/output (scl1) i/o port also functioning as external interrupt input ( ,54 , ,54 , ,54 ), sci1 input/output (txd1, rxd1, sck1), host interface control input/output ( &6 , ga20, ha0, hifsd), and i 2 c bus interface 1 (option) input/output (scl1) port 9 8-bit i/o port p97/ :$,7 /sda0 i/o port also functioning as expanded data bus control input ( :$,7 ) and i 2 c bus interface 0 (option) input/output (sda0) i/o port also functioning as i 2 c bus interface 0 (option) input/output (sda0) p96/?/excl when ddr = 0: input port or excl input when ddr = 1 (after reset): ? output when ddr = 0 (after reset): input port or excl input when ddr = 1: ? output p95/ $6 / ,26 / &6 p94/ +:5 / ,2: p93/ 5' / ,25 expanded data bus control output ( $6 / ,26 , +:5 , 5' ) i/o port also functioning as host interface control input ( &6 , ,2: , ,25 )
195 table 8.1 h8s/2148 series port functions (cont) expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 9 8-bit i/o port p92/ ,54 p91/ ,54 i/o port also functioning as external interrupt input ( ,54 , ,54 ) p90/ /:5 / ,54 / $'75* / (&6 2 i/o port also functioning as expanded data bus control output ( /:5 ), external interrupt input ( ,54 ), and a/d converter external trigger input ( $'75* ) i/o port also functioning as external interrupt input ( ,54 ), a/d converter external trigger input ( $'75* ), and host interface control input ( (&6 ) port a 8-bit i/o port pa7/a23/ .,1 / cin15/ps2cd pa6/a22/ .,1 / cin14/ps2cc pa5/a21/ .,1 / cin13/ps2bd pa4/a20/ .,1 / cin12/ps2bc pa3/a19/ .,1 / cin11/ps2ad pa2/a18/ .,1 / cin10/ps2ac pa1/a17/ .,1 / cin9 pa0/a16/ .,1 / cin8 i/o port also functioning as key-sense interrupt input ( .,1 to .,1 ), expansion a/d converter input (cin15 to cin8), and keyboard buffer controller input/output (ps2cd, ps2cc, ps2bd, ps2bc, ps2ad, ps2ac) input port also functioning as address output (a23 to a16), key- sense interrupt input ( .,1 to .,1 ), expansion a/d converter input (cin15 to cin8), and keyboard buffer controller input/output (ps2cd, ps2cc, ps2bd, ps2bc, ps2ad, ps2ac) i/o port also functioning as key-sense interrupt input ( .,1 to .,1 ), expansion a/d converter input (cin15 to cin8), and keyboard buffer controller input/output (ps2cd, ps2cc, ps2bd, ps2bc, ps2ad, ps2ac) port b 8-bit i/o port pb7/d7 pb6/d6 pb5/d5 pb4/d4 pb3/d3/ &6 pb2/d2/ &6 pb1/d1/hirq4 pb0/d0/hirq3 in 8-bit bus mode (abw = 1): i/o port in 16-bit bus mode (abw = 0): data bus input/output (d7 to d0) i/o port also functioning as hif control input/ output pins ( &6 , &6 , hirq3, hirq4)
196 table 8.2 h8s/2144 series port functions expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 1 8-bit i/o port built-in mos input pull-ups led drive capability p17 to p10/ a7 to a0 lower address output (a7 to a0) when ddr = 0 (after reset): input port when ddr = 1: lower address output (a7 to a0) i/o port port 2 8-bit i/o port built-in mos input pull-ups led drive capability p27 to p20/ a15 to a8 upper address output (a15 to a8) when ddr = 0 (after reset): input port when ddr = 1: upper address output (a15 to a8) or output port (p27 to p24) i/o port port 3 8-bit i/o port built-in mos input pull-ups led drive capability p37 to p30/ d15 to d8 data bus input/output (d15 to d8) i/o port port 4 8-bit i/o port p47/pwx1 p46/pwx0 p45/tmri1 p44/tmo1 p43/tmci1 p42/tmri0/sck2 p41/tmo0/rxd2/ irrxd p40/tmci0/ txd2/irtxd i/o port also functioning as 14-bit pwm timer output (pwx1, pwx0), 8-bit timer 0 and 1 input/output (tmci0, tmri0, tmo0, tmci1, tmri1, tmo1), sci2 input/output (txd2, rxd2, sck2), and irda interface input/output (irtxd, irrxd) port 5 3-bit i/o port p52/sck0 p51/rxd0 p50/txd0 i/o port also functioning as sci0 input/output (txd0, rxd0, sck0)
197 table 8.2 h8s/2144 series port functions (cont) expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 6 8-bit i/o port p67/ ,54 / .,1 / cin7 p66/ ,54 /ftob/ .,1 /cin6 p65/ftid/ .,1 / cin5 p64/ftic/ .,1 / cin4 p63/ftib/ .,1 / cin3 p62/ftia/tmiy/ .,1 /cin2 p61/ftoa/ .,1 /cin 1 p60/ftci/ .,1 / cin0 i/o port also functioning as external interrupt input ( ,54 , ,54 ), frt input/output (ftci, ftoa, ftia, ftib, ftic, ftid, ftob), 8- bit timer y input (tmiy), key-sense interrupt input ( .,1 to .,1 ), and expansion a/d converter input (cin7 to cin0) port 7 8-bit input port p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 input port also functioning as a/d converter analog input (an7 to an0) and d/a converter analog output (da1, da0) port 8 7-bit i/o port p86/ ,54 /sck1 p85/ ,54 /rxd1 p84/ ,54 /txd1 p83 p82 p81 p80 i/o port also functioning as external interrupt input ( ,54 , ,54 , ,54 ) and sci1 input/output (txd1, rxd1, sck1)
198 table 8.2 h8s/2144 series port functions (cont) expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 9 8-bit i/o port p97/ :$,7 i/o port also functioning as expanded data bus control input ( :$,7 ) i/o port p96/?/excl when ddr = 0: input port or excl input when ddr = 1 (after reset): ? output when ddr = 0 (after reset): input port or excl input when ddr = 1: ? output p95/ $6 / ,26 p94/ +:5 p93/ 5' expanded data bus control output( $6 / ,26 , +:5 , 5' ) i/o port p92/ ,54 p91/ ,54 i/o port also functioning as external interrupt input ( ,54 , ,54 ) p90/ /:5 / ,54 / $'75* i/o port also functioning as expanded data bus control output( /:5 ), external interrupt input ( ,54 ), and a/d converter external trigger input ( $'75* ) i/o port also functioning as external interrupt input ( ,54 ) and a/d converter external trigger input ( $'75* ) port a 8-bit i/o port pa7 to pa0/ a23 to a16/ .,1 to .,1 / cin15 to cin8 i/o port also functioning as key-sense interrupt input ( .,1 to .,1 ), and expansion a/d converter input (cin15 to cin8) input port also functioning as address output (a23 to a16), key- sense interrupt input ( .,1 to .,1 ), and expansion a/d converter input (cin15 to cin8) i/o port also functioning as key-sense interrupt input ( .,1 to .,1 ) and expansion a/d converter input (cin15 to cin8) port b 8-bit i/o port pb7 to pb0/ d7 to d0 in 8-bit bus mode (abw = 1): i/o port in 16-bit bus mode (abw = 0): data bus input/output (d7 to d0) i/o port
199 8.2 port 1 8.2.1 overview port 1 is an 8-bit i/o port. port 1 pins also function as address bus output pins (a7 to a0), and as 8-bit pwm output pins (pw7 to pw0) (h8s/2148 series only). port 1 functions change according to the operating mode. port 1 has a built-in mos input pull-up function that can be controlled by software. figure 8.1 shows the port 1 pin configuration. p17/a7/pw7 p16/a6/pw6 p15/a5/pw5 p14/a4/pw4 p13/a3/pw3 p12/a2/pw2 p11/a1/pw1 p10/a0/pw0 port 1 port 1 pins a7 (output) a6 (output) a5 (output) a4 (output) a3 (output) a2 (output) a1 (output) a0 (output) pin functions in mode 1 a7 (output)/p17 (input)/pw7 (output) a6 (output)/p16 (input)/pw6 (output) a5 (output)/p15 (input)/pw5 (output) a4 (output)/p14 (input)/pw4 (output) a3 (output)/p13 (input)/pw3 (output) a2 (output)/p12 (input)/pw2 (output) a1 (output)/p11 (input)/pw1 (output) a0 (output)/p10 (input)/pw0 (output) pin functions in modes 2 and 3 (expe = 1) p17 (i/o)/pw7 (output) p16 (i/o)/pw6 (output) p15 (i/o)/pw5 (output) p14 (i/o)/pw4 (output) p13 (i/o)/pw3 (output) p12 (i/o)/pw2 (output) p11 (i/o)/pw1 (output) p10 (i/o)/pw0 (output) pin functions in modes 2 and 3 (expe = 0) figure 8.1 port 1 pin functions
200 8.2.2 register configuration table 8.3 shows the port 1 register configuration. table 8.3 port 1 registers name abbreviation r/w initial value address * port 1 data direction register p1ddr w h'00 h'ffb0 port 1 data register p1dr r/w h'00 h'ffb2 port 1 mos pull-up control register p1pcr r/w h'00 h'ffac note: * lower 16 bits of the address. port 1 data direction register (p1ddr) 7 p17ddr 0 w 6 p16ddr 0 w 5 p15ddr 0 w 4 p14ddr 0 w 3 p13ddr 0 w 0 p10ddr 0 w 2 p12ddr 0 w 1 p11ddr 0 w bit initial value read/write p1ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 1. p1ddr cannot be read; if it is, an undefined value will be returned. p1ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. the address output pins maintain their output state in a transition to software standby mode. mode 1 the corresponding port 1 pins are address outputs, regardless of the p1ddr setting. in hardware standby mode, the address outputs go to the high-impedance state. modes 2 and 3 (expe = 1) the corresponding port 1 pins are address outputs or pwm outputs when p1ddr bits are set to 1, and input ports when cleared to 0. modes 2 and 3 (expe = 0) the corresponding port 1 pins are output ports or pwm outputs when p1ddr bits are set to 1, and input ports when cleared to 0.
201 port 1 data register (p1dr) 7 p17dr 0 r/w 6 p16dr 0 r/w 5 p15dr 0 r/w 4 p14dr 0 r/w 3 p13dr 0 r/w 0 p10dr 0 r/w 2 p12dr 0 r/w 1 p11dr 0 r/w bit initial value r/w p1dr is an 8-bit readable/writable register that stores output data for the port 1 pins (p17 to p10). if a port 1 read is performed while p1ddr bits are set to 1, the p1dr values are read directly, regardless of the actual pin states. if a port 1 read is performed while p1ddr bits are cleared to 0, the pin states are read. p1dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 1 mos pull-up control register (p1pcr) 7 p17pcr 0 r/w 6 p16pcr 0 r/w 5 p15pcr 0 r/w 4 p14pcr 0 r/w 3 p13pcr 0 r/w 0 p10pcr 0 r/w 2 p12pcr 0 r/w 1 p11pcr 0 r/w bit initial value r/w p1pcr is an 8-bit readable/writable register that controls the port 1 built-in mos input pull-ups on a bit-by-bit basis. in modes 2 and 3, the mos input pull-up is turned on when a p1pcr bit is set to 1 while the corresponding p1ddr bit is cleared to 0 (input port setting). p1pcr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
202 8.2.3 pin functions in each mode mode 1: in mode 1, port 1 pins automatically function as address outputs. the port 1 pin functions are shown in figure 8.2. a7 (output) a6 (output) a5 (output) a4 (output) a3 (output) a2 (output) a1 (output) a0 (output) port 1 figure 8.2 port 1 pin functions (mode 1) modes 2 and 3 (expe = 1): in modes 2 and 3 (when expe = 1), port 1 pins function as address outputs, pwm outputs, or input ports, and input or output can be specified on a bit-by-bit basis. when a bit in p1ddr is set to 1, the corresponding pin functions as an address output or pwm output, and when cleared to 0, as an input port. the port 1 pin functions are shown in figure 8.3. a7 (output) a6 (output) a5 (output) a4 (output) a3 (output) a2 (output) a1 (output) a0 (output) port 1 when p1ddr = 1 and pwoera = 0 p17 (input) p16 (input) p15 (input) p14 (input) p13 (input) p12 (input) p11 (input) p10 (input) when p1ddr = 0 pw7 (output) pw6 (output) pw5 (output) pw4 (output) pw3 (output) pw2 (output) pw1 (output) pw0 (output) when p1ddr = 1 and pwoera = 1 figure 8.3 port 1 pin functions (modes 2 and 3 (expe = 1))
203 modes 2 and 3 (expe = 0): in modes 2 and 3 (when expe = 0), port 1 pins function as pwm outputs or i/o ports, and input or output can be specified on a bit-by-bit basis. when a bit in p1ddr is set to 1, the corresponding pin functions as a pwm output or output port, and when cleared to 0, as an input port. the port 1 pin functions are shown in figure 8.4. p17 (i/o) p16 (i/o) p15 (i/o) p14 (i/o) p13 (i/o) p12 (i/o) p11 (i/o) p10 (i/o) port 1 p1n: input pin when p1ddr = 0, output pin when p1ddr = 1 and pwoera = 0 pw7 (output) pw6 (output) pw5 (output) pw4 (output) pw3 (output) pw2 (output) pw1 (output) pw0 (output) when p1ddr = 1 and pwoera = 1 figure 8.4 port 1 pin functions (modes 2 and 3 (expe = 0))
204 8.2.4 mos input pull-up function port 1 has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in modes 2 and 3, and can be specified as on or off on a bit- by-bit basis. when a p1ddr bit is cleared to 0 in mode 2 or 3, setting the corresponding p1pcr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.4 summarizes the mos input pull-up states. table 8.4 mos input pull-up states (port 1) mode reset hardware standby mode software standby mode in other operations 1 off off off off 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when p1ddr = 0 and p1pcr = 1; otherwise off.
205 8.3 port 2 8.3.1 overview port 2 is an 8-bit i/o port. port 2 pins also function as address bus output pins (a15 to a8), 8-bit pwm output pins (pw15 to pw8) (h8s/2148 series only), and the timer connection output pin (cblank) (h8s/2148 series only). port 2 functions change according to the operating mode. port 2 has a built-in mos input pull-up function that can be controlled by software. figure 8.5 shows the port 2 pin configuration. p27/a15/pw15/cblank p26/a14/pw14 p25/a13/pw13 p24/a12/pw12 p23/a11/pw11 p22/a10/pw10 p21/a9/pw9 p20/a8/pw8 port 2 port 2 pins a15 (output) a14 (output) a13 (output) a12 (output) a11 (output) a10 (output) a9 (output) a8 (output) pin functions in mode 1 a15 (output)/p27 (i/o)/pw15 (output)/cblank (output) a14 (output)/p26 (i/o)/pw14 (output) a13 (output)/p25 (i/o)/pw13 (output) a12 (output)/p24 (i/o)/pw12 (output) a11 (output)/p23 (input)/pw11 (output) a10 (output)/p22 (input)/pw10 (output) a9 (output)/p21 (input)/pw9 (output) a8 (output)/p20 (input)/pw8 (output) pin functions in modes 2 and 3 (expe = 1) p27 (i/o)/pw15 (output)/cblank (output) p26 (i/o)/pw14 (output) p25 (i/o)/pw13 (output) p24 (i/o)/pw12 (output) p23 (i/o)/pw11 (output) p22 (i/o)/pw10 (output) p21 (i/o)/pw9 (output) p20 (i/o)/pw8 (output) pin functions in modes 2 and 3 (expe = 0) figure 8.5 port 2 pin functions
206 8.3.2 register configuration table 8.5 shows the port 2 register configuration. table 8.5 port 2 registers name abbreviation r/w initial value address * port 2 data direction register p2ddr w h'00 h'ffb1 port 2 data register p2dr r/w h'00 h'ffb3 port 2 mos pull-up control register p2pcr r/w h'00 h'ffad note: * lower 16 bits of the address. port 2 data direction register (p2ddr) 7 p27ddr 0 w 6 p26ddr 0 w 5 p25ddr 0 w 4 p24ddr 0 w 3 p23ddr 0 w 0 p20ddr 0 w 2 p22ddr 0 w 1 p21ddr 0 w bit initial value read/write p2ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 2. p2ddr cannot be read; if it is, an undefined value will be returned. p2ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. the address output pins maintain their output state in a transition to software standby mode. mode 1 the corresponding port 2 pins are address outputs, regardless of the p2ddr setting. in hardware standby mode, the address outputs go to the high-impedance state. modes 2 and 3 (expe = 1) the corresponding port 2 pins are address outputs or pwm outputs when p2ddr bits are set to 1, and input ports when cleared to 0. p27 to p24 are switched from address outputs to output ports by setting the iose bit to 1. p27 can be used as an on-chip supporting module output pin regardless of the p27ddr setting, but to ensure normal access to external space, p27 should not be set as an on-chip supporting module output pin when port 2 pins are used as address output pins.
207 modes 2 and 3 (expe = 0) the corresponding port 2 pins are output ports or pwm outputs when p2ddr bits are set to 1, and input ports when cleared to 0. p27 can be used as an on-chip supporting module output pin regardless of the p27ddr setting. port 2 data register (p2dr) 7 p27dr 0 r/w 6 p26dr 0 r/w 5 p25dr 0 r/w 4 p24dr 0 r/w 3 p23dr 0 r/w 0 p20dr 0 r/w 2 p22dr 0 r/w 1 p21dr 0 r/w bit initial value r/w p2dr is an 8-bit readable/writable register that stores output data for the port 2 pins (p27 to p20). if a port 2 read is performed while p2ddr bits are set to 1, the p2dr values are read directly, regardless of the actual pin states. if a port 2 read is performed while p2ddr bits are cleared to 0, the pin states are read. p2dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 2 mos pull-up control register (p2pcr) 7 p27pcr 0 r/w 6 p26pcr 0 r/w 5 p25pcr 0 r/w 4 p24pcr 0 r/w 3 p23pcr 0 r/w 0 p20pcr 0 r/w 2 p22pcr 0 r/w 1 p21pcr 0 r/w bit initial value r/w p2pcr is an 8-bit readable/writable register that controls the port 2 built-in mos input pull-ups on a bit-by-bit basis. in modes 2 and 3, the mos input pull-up is turned on when a p2pcr bit is set to 1 while the corresponding p2ddr bit is cleared to 0 (input port setting). p2pcr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
208 8.3.3 pin functions in each mode mode 1: in mode 1, port 2 pins automatically function as address outputs. the port 2 pin functions are shown in figure 8.6. a15 (output) a14 (output) a13 (output) a12 (output) a11 (output) a10 (output) a9 (output) a8 (output) port 2 figure 8.6 port 2 pin functions (mode 1) modes 2 and 3 (expe = 1): in modes 2 and 3 (when expe = 1), port 2 pins function as address outputs, pwm outputs, or i/o ports, and input or output can be specified on a bit-by-bit basis. when a bit in p2ddr is set to 1, the corresponding pin functions as an address output or pwm output, and when cleared to 0, as an input port. p27 to p24 are switched from address outputs to output ports by setting the iose bit to 1. p27 can be used as an on-chip supporting module output pin regardless of the p27ddr setting, but to ensure normal access to external space, p27 should not be set as an on-chip supporting module output pin when port 2 pins are used as address output pins. the port 2 pin functions are shown in figure 8.7. a15 (output)/p27 (output) a14 (output)/p26 (output) a13 (output)/p25 (output) a12 (output)/p24 (output) a11 (output) a10 (output) a9 (output) a8 (output) port 2 when p2ddr = 1 and pwoerb = 0 p27 (input)/cblank (output) p26 (input) p25 (input) p24 (input) p23 (input) p22 (input) p21 (input) p20 (input) when p2ddr = 0 pw15 (output)/cblank (output) pw14 (output) pw13 (output) pw12 (output) pw11 (output) pw10 (output) pw9 (output) pw8 (output) when p2ddr = 1 and pwoerb = 1 figure 8.7 port 2 pin functions (modes 2 and 3 (expe = 1))
209 modes 2 and 3 (expe = 0): in modes 2 and 3 (when expe = 0), port 2 pins function as pwm outputs (p27 can also function as the timer connection output (cblank)) or i/o ports, and input or output can be specified on a bit-by-bit basis. when a bit in p2ddr is set to 1, the corresponding pin functions as a pwm output or output port, and when cleared to 0, as an input port. p27 can be used as an on-chip supporting module output pin regardless of the p27ddr setting. the port 2 pin functions are shown in figure 8.8. p27 (i/o)/cblank (output) p26 (i/o) p25 (i/o) p24 (i/o) p23 (i/o) p22 (i/o) p21 (i/o) p20 (i/o) port 2 p2n: input pin when p2ddr = 0, output pin when p2ddr = 1 and pwoerb = 0 pw15 (output)/cblank (output) pw14 (output) pw13 (output) pw12 (output) pw11 (output) pw10 (output) pw9 (output) pw8 (output) when p2ddr = 1 and pwoerb = 1 figure 8.8 port 2 pin functions (modes 2 and 3 (expe = 0))
210 8.3.4 mos input pull-up function port 2 has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in modes 2 and 3, and can be specified as on or off on a bit- by-bit basis. when a p2ddr bit is cleared to 0 in mode 2 or 3, setting the corresponding p2pcr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.6 summarizes the mos input pull-up states. table 8.6 mos input pull-up states (port 2) mode reset hardware standby mode software standby mode in other operations 1 off off off off 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when p2ddr = 0 and p2pcr = 1; otherwise off.
211 8.4 port 3 8.4.1 overview port 3 is an 8-bit i/o port. port 3 pins also function as host data bus i/o pins (hdb7 to hdb0) (h8s/2148 series only), and as data bus i/o pins. port 3 functions change according to the operating mode. port 3 has a built-in mos input pull-up function that can be controlled by software. figure 8.9 shows the port 3 pin configuration. p37/d15/hdb7 p36/d14/hdb6 p35/d13/hdb5 p34/d12/hdb4 p33/d11/hdb3 p32/d10/hdb2 p31/d9/hdb1 p30/d8/hdb0 port 3 port 3 pins d15 (i/o) d14 (i/o) d13 (i/o) d12 (i/o) d11 (i/o) d10 (i/o) d9 (i/o) d8 (i/o) pin functions in modes 1, 2 and 3 (expe = 1) p37 (i/o)/hdb7 (i/o) p36 (i/o)/hdb6 (i/o) p35 (i/o)/hdb5 (i/o) p34 (i/o)/hdb4 (i/o) p33 (i/o)/hdb3 (i/o) p32 (i/o)/hdb2 (i/o) p31 (i/o)/hdb1 (i/o) p30 (i/o)/hdb0 (i/o) pin functions in modes 2 and 3 (expe = 0) figure 8.9 port 3 pin functions
212 8.4.2 register configuration table 8.7 shows the port 3 register configuration. table 8.7 port 3 registers name abbreviation r/w initial value address * port 3 data direction register p3ddr w h'00 h'ffb4 port 3 data register p3dr r/w h'00 h'ffb6 port 3 mos pull-up control register p3pcr r/w h'00 h'ffae note: * lower 16 bits of the address. port 3 data direction register (p3ddr) 7 p37ddr 0 w 6 p36ddr 0 w 5 p35ddr 0 w 4 p34ddr 0 w 3 p33ddr 0 w 0 p30ddr 0 w 2 p32ddr 0 w 1 p31ddr 0 w bit initial value read/write p3ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 3. p3ddr cannot be read; if it is, an undefined value will be returned. p3ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. modes 1, 2, and 3 (expe = 1) the input/output direction specified by p3ddr is ignored, and pins automatically function as data i/o pins. after a reset, and in hardware standby mode or software standby mode, the data i/o pins go to the high-impedance state. modes 2 and 3 (expe = 0) the corresponding port 3 pins are output ports when p3ddr bits are set to 1, and input ports when cleared to 0.
213 port 3 data register (p3dr) 7 p37dr 0 r/w 6 p36dr 0 r/w 5 p35dr 0 r/w 4 p34dr 0 r/w 3 p33dr 0 r/w 0 p30dr 0 r/w 2 p32dr 0 r/w 1 p31dr 0 r/w bit initial value read/write p3dr is an 8-bit readable/writable register that stores output data for the port 3 pins (p37 to p30). if a port 3 read is performed while p3ddr bits are set to 1, the p3dr values are read directly, regardless of the actual pin states. if a port 3 read is performed while p3ddr bits are cleared to 0, the pin states are read. p3dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 3 mos pull-up control register (p3pcr) 7 p37pcr 0 r/w 6 p36pcr 0 r/w 5 p35pcr 0 r/w 4 p34pcr 0 r/w 3 p33pcr 0 r/w 0 p30pcr 0 r/w 2 p32pcr 0 r/w 1 p31pcr 0 r/w bit initial value read/write p3pcr is an 8-bit readable/writable register that controls the port 3 built-in mos input pull-ups on a bit-by-bit basis. in modes 2 and 3 (when expe = 0), the mos input pull-up is turned on when a p3pcr bit is set to 1 while the corresponding p3ddr bit is cleared to 0 (input port setting). p3pcr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. the mos input pull-up function cannot be used in slave mode (when the host interface is enabled).
214 8.4.3 pin functions in each mode modes 1, 2, and 3 (expe = 1): in modes 1, 2, and 3 (when expe = 1), port 3 pins automatically function as data i/o pins. the port 3 pin functions are shown in figure 8.10. d15 (i/o) d14 (i/o) d13 (i/o) d12 (i/o) d11(i/o) d10 (i/o) d9 (i/o) d8 (i/o) port 3 figure 8.10 port 3 pin functions (modes 1, 2, and 3 (expe = 1)) modes 2 and 3 (expe = 0): in modes 2 and 3 (when expe = 0), port 3 functions as host interface data bus i/o pins (hdb7 to hdb0) or as i/o ports. when the hi12e bit is set to 1 in syscr2 and a transition is made to slave mode, port 3 functions as the host interface data bus. in slave mode, p3dr and p3ddr should be cleared to h'00. when the hi12e bit is cleared to 0, port 3 functions as an i/o port, and input or output can be specified on a bit-by-bit basis. when a bit in p3ddr is set to 1, the corresponding pin functions as an output port, and when cleared to 0, as an input port. the port 3 pin functions are shown in figure 8.11. p37 (i/o)/hdb7 (i/o) p36 (i/o)/hdb6 (i/o) p35 (i/o)/hdb5 (i/o) p34 (i/o)/hdb4 (i/o) p33 (i/o)/hdb3 (i/o) p32 (i/o)/hdb2 (i/o) p31 (i/o)/hdb1 (i/o) p30 (i/o)/hdb0 (i/o) port 3 figure 8.11 port 3 pin functions (modes 2 and 3 (expe = 0))
215 8.4.4 mos input pull-up function port 3 has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in modes 2 and 3 (when expe = 0), and can be specified as on or off on a bit-by-bit basis. when a p3ddr bit is cleared to 0 in mode 2 or 3 (when expe = 0), setting the corresponding p3pcr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.8 summarizes the mos input pull-up states. table 8.8 mos input pull-up states (port 3) mode reset hardware standby mode software standby mode in other operations 1, 2, 3 (expe = 1) off off off off 2, 3 (expe = 0) off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when p3ddr = 0 and p3pcr = 1; otherwise off.
216 8.5 port 4 8.5.1 overview port 4 is an 8-bit i/o port. port 4 pins also function as 14-bit pwm output pins (pwx1, pwx0), 8-bit timer 0 and 1 (tmr0, tmr1) i/o pins (tmci0, tmri0, tmo0, tmci1, tmri1, tmo1), timer connection i/o pins (csynci, hsynci, hsynco) (h8s/2148 series only), sci2 i/o pins (txd2, rxd2, sck2), irda interface i/o pins (irtxd, irrxd), host interface output pins (hirq12, hirq1, hirq11) (h8s/2148 series only), and the iic1 i/o pin (sda1) (option in h8s/2148 series only). port 4 pin functions are the same in all operating modes. figure 8.12 shows the port 4 pin configuration. p47 (i/o)/pwx1 (output) p46 (i/o)/pwx0 (output) p45 (i/o)/tmri1 (input)/hirq12 (output)/csynci (input) p44 (i/o)/tmo1 (output)/hirq1 (output)/hsynco (output) p43 (i/o)/tmci1 (input)/hirq11 (output)/hcynci (input) p42 (i/o)/tmri0 (input)/sck2 (i/o)/sda1 (i/o) p41 (i/o)/tmo0 (output)/rxd2 (input)/irrxd (input) p40 (i/o)/tmci0 (input)/txd2 (output)/irtxd (output) port 4 port 4 pins figure 8.12 port 4 pin functions
217 8.5.2 register configuration table 8.9 shows the port 4 register configuration. table 8.9 port 4 registers name abbreviation r/w initial value address * port 4 data direction register p4ddr w h'00 h'ffb5 port 4 data register p4dr r/w h'00 h'ffb7 note: * lower 16 bits of the address. port 4 data direction register (p4ddr) 7 p47ddr 0 w 6 p46ddr 0 w 5 p45ddr 0 w 4 p44ddr 0 w 3 p43ddr 0 w 0 p40ddr 0 w 2 p42ddr 0 w 1 p41ddr 0 w bit initial value read/write p4ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 4. p4ddr cannot be read; if it is, an undefined value will be returned. when a bit in p4ddr is set to 1, the corresponding pin functions as an output port, and when cleared to 0, as an input port. p4ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. as 14-bit pwm and sci2 are initialized in software standby mode, the pin states are determined by the tmr0, tmr1, hif, iic1, p4ddr, and p4dr specifications. port 4 data register (p4dr) 7 p47dr 0 r/w 6 p46dr 0 r/w 5 p45dr 0 r/w 4 p44dr 0 r/w 3 p43dr 0 r/w 0 p40dr 0 r/w 2 p42dr 0 r/w 1 p41dr 0 r/w bit initial value read/write p4dr is an 8-bit readable/writable register that stores output data for the port 4 pins (p47 to p40). if a port 4 read is performed while p4ddr bits are set to 1, the p4dr values are read directly, regardless of the actual pin states. if a port 4 read is performed while p4ddr bits are cleared to 0, the pin states are read. p4dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
218 8.5.3 pin functions port 4 pins also function as 14-bit pwm output pins (pwx1, pwx0), 8-bit timer 0 and 1 (tmr0, tmr1) i/o pins (tmci0, tmri0, tmo0, tmci1, tmri1, tmo1), timer connection i/o pins (csynci, hsynci, hsynco), sci2 i/o pins (txd2, rxd2, sck2), irda interface i/o pins (irtxd, irrxd), host interface output pins (hirq12, hirq1, hirq11), and the iic1 i/o pin (sda1). the port 4 pin functions are shown in table 8.10. table 8.10 port 4 pin functions pin selection method and pin functions p47/pwx1 the pin function is switched as shown below according to the combination of bit oeb in dacr of 14-bit pwm, and bit p47ddr. oeb 0 1 p47ddr 0 1 pin function p47 input pin p47 output pin pwx1 output pin p46/pwx0 the pin function is switched as shown below according to the combination of bit oea in dacr of 14-bit pwm, and bit p46ddr. oea 0 1 p46ddr 0 1 pin function p46 input pin p46 output pin pwx0 output pin p45/tmri1/ hirq12/csynci the pin function is switched as shown below according to the combination of the operating mode and bit p45ddr. p45ddr 0 1 operating mode not slave mode slave mode pin function p45 input pin p45 output pin hirq12 output pin tmri1 input pin, csynci input pin when bits cclr1 and cclr0 in tcr1 of tmr1 are set to 1, this pin is used as the tmri1 input pin. it can also be used as the csynci input pin. p44/tmo1/ hirq1/hsynco the pin function is switched as shown below according to the combination of the operating mode, bits os3 to os0 in tcsr of tmr1, bit hoe in tconro of the timer connection function, and bit p44ddr. hoe 0 1 os3 to os0 all 0 not all 0 p44ddr 0 1 operating mode not slave mode slave mode pin function p44 input pin p44 output pin hirq1 output pin tmo1 output pin hsynco output pin
219 table 8.10 port 4 pin functions (cont) pin selection method and pin functions p43/tmci1/ hirq11/hsynci the pin function is switched as shown below according to the combination of the operating mode and bit p43ddr. p43ddr 0 1 operating mode not slave mode slave mode pin function p43 input pin p43 output pin hirq11 output pin tmci1 input pin, hsynci input pin when an external clock is selected with bits cks2 to cks0 in tcr1 of tmr1, this pin is used as the tmci1 input pin. it can also be used as the hsynci input pin. p42/tmri0/ sck2/sda1 the pin function is switched as shown below according to the combination of bit ice in iccr of iic1, bits cke1 and cke0 in scr of sci2, bit c/ $ in smr of sci2, and bit p42ddr. ice 0 1 cke1 0 1 0 c/ $ 010 cke0 0 1 0 p42ddr 0 1 pin function p42 input pin p42 output pin sck2 output pin sck2 output pin sck2 input pin sda1 i/o pin tmri0 input pin when this pin is used as the sda1 i/o pin, bits cke1 and cke0 in scr of sci2 and bit c/ $ in smr of sci2 must all be cleared to 0. sda1 is an nmos- only output, and has direct bus drive capability. when bits cclr1 and cclr0 in tcr0 of tmr0 are set to 1, this pin is used as the tmri0 input pin.
220 table 8.10 port 4 pin functions (cont) pin selection method and pin functions p41/tmo0/rxd2/ irrxd the pin function is switched as shown below according to the combination of bits os3 to os0 in tcsr of tmr0, bit re in scr of sci2 and bit p41ddr. os3 to os0 all 0 not all 0 re 0 1 0 p41ddr 0 1 pin function p41 input pin p41 output pin rxd2/irrxd input pin tmo0 output pin when this pin is used as the tmo0 output pin, bit re in scr of sci2 must be cleared to 0. p40/tmci0/txd2/ irtxd the pin function is switched as shown below according to the combination of bit te in scr of sci2 and bit p40ddr. te 0 1 p40ddr 0 1 pin function p40 input pin p40 output pin txd2/irtxd output pin tmci0 input pin when an external clock is selected with bits cks2 to cks0 in tcr0 of tmr0, this pin is used as the tmci0 input pin.
221 8.6 port 5 8.6.1 overview port 5 is a 3-bit i/o port. port 5 pins also function as sci0 i/o pins (txd0, rxd0, sck0), and the iic0 i/o pin (scl0) (option in h8s/2148 series only). in the h8s/2148 series, p52 and sck0 are nmos push-pull outputs, and scl0 is an nmos open-drain output. port 5 pin functions are the same in all operating modes. figure 8.13 shows the port 5 pin configuration. p52 (i/o)/sck0 (i/o)/scl0 (i/o) p51 (i/o)/rxd0 (input) p50 (i/o)/txd0 (output) port 5 port 5 pins figure 8.13 port 5 pin functions 8.6.2 register configuration table 8.11 shows the port 5 register configuration. table 8.11 port 5 registers name abbreviation r/w initial value address * port 5 data direction register p5ddr w h'f8 h'ffb8 port 5 data register p5dr r/w h'f8 h'ffba note: * lower 16 bits of the address.
222 port 5 data direction register (p5ddr) 7 ? 1 6 ? 1 5 ? 1 4 ? 1 3 ? 1 0 p50ddr 0 w 2 p52ddr 0 w 1 p51ddr 0 w bit initial value read/write p5ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 5. p5ddr cannot be read; if it is, an undefined value will be returned. bits 7 to 3 are reserved. setting a p5ddr bit to 1 makes the corresponding port 5 pin an output pin, while clearing the bit to 0 makes the pin an input pin. p5ddr is initialized to h'f8 by a reset and in hardware standby mode. it retains its prior state in software standby mode. as sci0 is initialized, the pin states are determined by the iic0 iccr, p5ddr, and p5dr specifications. port 5 data register (p5dr) 7 ? 1 6 ? 1 5 ? 1 4 ? 1 3 ? 1 0 p50dr 0 r/w 2 p52dr 0 r/w 1 p51dr 0 r/w bit initial value read/write p5dr is an 8-bit readable/writable register that stores output data for the port 5 pins (p52 to p50). if a port 5 read is performed while p5ddr bits are set to 1, the p5dr values are read directly, regardless of the actual pin states. if a port 5 read is performed while p5ddr bits are cleared to 0, the pin states are read. bits 7 to 3 are reserved; they cannot be modified and are always read as 1. p5dr is initialized to h'f8 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
223 8.6.3 pin functions port 5 pins also function as sci0 i/o pins (txd0, rxd0, sck0) and the iic0 i/o pin (scl0). the port 5 pin functions are shown in table 8.12. table 8.12 port 5 pin functions pin selection method and pin functions p52/sck0/scl0 the pin function is switched as shown below according to the combination of bits cke1 and cke0 in scr of sci0, bit c/ $ in smr of sci0, bit ice in iccr of iic0, and bit p52ddr. ice 0 1 cke1 0 1 0 c/ $ 010 cke0 0 1 0 p52ddr 0 1 pin function p52 input pin p52 output pin sck0 output pin sck0 output pin sck0 input pin scl0 i/o pin when this pin is used as the scl0 i/o pin, bits cke1 and cke0 in scr of sci0 and bit c/ $ in smr of sci0 must all be cleared to 0. scl0 is an nmos open-drain output, and has direct bus drive capability. in the h8s/2148 series, when set as the p52 output pin or sck0 output pin, this pin is an nmos push-pull output. p51/rxd0 the pin function is switched as shown below according to the combination of bit re in scr of sci0 and bit p51ddr. re 0 1 p51ddr 0 1 pin function p51 input pin p51 output pin rxd0 input pin p50/txd0 the pin function is switched as shown below according to the combination of bit te in scr of sci0 and bit p50ddr. te 0 1 p50ddr 0 1 pin function p50 input pin p50 output pin txd0 output pin
224 8.7 port 6 8.7.1 overview port 6 is an 8-bit i/o port. port 6 pins also function as the 16-bit free-running timer (frt) i/o pins (ftoa, ftob, ftia to ftid, ftci), timer x (tmrx) i/o pins (tmox, tmix) (h8s/2148 series only), the timer y (tmry) input pin (tmiy), timer connection i/o pins (hfbacki, vsynci, vsynco, vfbacki, clampo) (h8s/2148 series only), key-sense interrupt input pins ( .,1 to .,1 ), expansion a/d converter input pins (cin7 to cin0), and external interrupt input pins ( ,54 , ,54 ). in the h8s/2148 series, the port 6 input level can be switched in four stages. port 6 pin functions are the same in all operating modes. figure 8.14 shows the port 6 pin configuration. p67 (i/o)/tmox (output)/ kin7 (input)/cin7 (input)/ irq7 (input) p66 (i/o)/ftob (output)/ kin6 (input)/cin6 (input)/ irq6 (input) p65 (i/o)/ftid (input)/ kin5 (input)/cin5 (input) p64 (i/o)/ftic (input)/ kin4 (input)/cin4 (input)/clampo (output) p63 (i/o)/ftib (input)/ kin3 (input)/cin3 (input)/vfbacki (input) p62 (i/o)/ftia (input)/ kin2 (input)/cin2 (input)/vsynci (input)/tmiy (input) p61 (i/o)/ftoa (output)/ kin1 (input)/cin1 (input)/vsynco (output) p60 (i/o)/ftci (input)/ kin0 (input)/cin0 (input)/hfbacki (input)/tmix (input) port 6 port 6 pins figure 8.14 port 6 pin functions
225 8.7.2 register configuration table 8.13 shows the port 6 register configuration. table 8.13 port 6 registers name abbreviation r/w initial value address * 1 port 6 data direction register p6ddr w h'00 h'ffb9 port 6 data register p6dr r/w h'00 h'ffbb port 6 mos pull-up control register kmpcr r/w h'00 h'fff2 * 2 system control register syscr2 r/w h'00 h'ff83 notes: 1. lower 16 bits of the address. 2. kmpcr has the same address as ticrr/tcoray of tmrx/tmry. to select kmpcr, set the hie bit to 1 in syscr and set the mstp2 bit to 0 in mstpcrl. port 6 data direction register (p6ddr) 7 p67ddr 0 w 6 p66ddr 0 w 5 p65ddr 0 w 4 p64ddr 0 w 3 p63ddr 0 w 0 p60ddr 0 w 2 p62ddr 0 w 1 p61ddr 0 w bit initial value read/write p6ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 6. p6ddr cannot be read; if it is, an undefined value will be returned. setting a p6ddr bit to 1 makes the corresponding port 6 pin an output pin, while clearing the bit to 0 makes the pin an input pin. p6ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
226 port 6 data register (p6dr) 7 p67dr 0 r/w 6 p66dr 0 r/w 5 p65dr 0 r/w 4 p64dr 0 r/w 3 p63dr 0 r/w 0 p60dr 0 r/w 2 p62dr 0 r/w 1 p61dr 0 r/w bit initial value read/write p6dr is an 8-bit readable/writable register that stores output data for the port 6 pins (p67 to p60). if a port 6 read is performed while p6ddr bits are set to 1, the p6dr values are read directly, regardless of the actual pin states. if a port 6 read is performed while p6ddr bits are cleared to 0, the pin states are read. p6dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 6 mos pull-up control register (kmpcr) bit 76543210 km7pcr km6pcr km5pcr km4pcr km3pcr km2pcr km1pcr km0pcr initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w kmpcr is an 8-bit readable/writable register that controls the port 6 built-in mos input pull- ups on a bit-by-bit basis. the mos input pull-up is turned on when a kmpcr bit is set to 1 while the corresponding p6ddr bit is cleared to 0 (input port setting). kmpcr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
227 system control register 2 (syscr2) (h8s/2148 series only) bit 76543210 kwul1 kwul0 p6pue sde cs4e cs3e hi12e initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w syscr2 is an 8-bit readable/writable register that controls port 6 input level selection and the operation of host interface functions. only bits 7, 6, and 5 are described here. see section 18.2.2, system control register 2 (syscr2), for information on bits 4 to 0. syscr2 is initialized to h'00 by a reset and in hardware standby mode. bits 7 and 6key wakeup level 1 and 0 (kwul1, kwul0): the port 6 input level setting can be changed by software, using these bits. the setting of these bits also changes the input level of the pin functions multiplexed with port 6. bit 7 bit 6 kwul1 kwul0 description 0 0 standard input level is selected as port 6 input level (initial value) 1 input level 1 is selected as port 6 input level 1 0 input level 2 is selected as port 6 input level 1 input level 3 is selected as port 6 input level bit 5port 6 input pull-up extra (p6pue): controls and selects the current specification for the port 6 mos input pull-up function connected by means of kmpcr settings. bit 5 p6pue description 0 standard current specification is selected for port 6 mos input pull-up function (initial value) 1 current-limit specification is selected for port 6 mos input pull-up function
228 8.7.3 pin functions port 6 pins also function as the 16-bit free-running timer (frt) i/o pins (ftoa, ftob, ftia to ftid, ftci), timer x (tmrx) i/o pins (tmox, tmix), the timer y (tmry) input pin (tmiy), timer connection i/o pins (hfbacki, vsynci, vsynco, vfbacki, clampo), key-sense interrupt input pins ( .,1 to .,1 ), comparator input pins (cin7 to cin0), and external interrupt input pins ( ,54 , ,54 ). in the h8s/2148 series, the port 6 input level can be switched in four stages. the port 6 pin functions are shown in table 8.14. table 8.14 port 6 pin functions pin selection method and pin functions p67/tmox/ ,54 / .,1 /cin7 the pin function is switched as shown below according to the combination of bits os3 to os0 in tcsr of tmrx and bit p67ddr. os3 to os0 all 0 not all 0 p67ddr 0 1 pin function p67 input pin p67 output pin tmox output pin ,54 input pin, .,1 input pin, cin7 input pin this pin is used as the ,54 input pin when bit irq7e is set to 1 in ier. it can always be used as the .,1 or cin7 input pin. p66/ftob/ ,54 / .,1 /cin6 the pin function is switched as shown below according to the combination of bit oeb in tocr of the frt and bit p66ddr. oeb 0 1 p66ddr 0 1 pin function p66 input pin p66 output pin ftob output pin ,54 input pin, .,1 input pin, cin6 input pin this pin is used as the ,54 input pin when bit irq6e is set to 1 in ier. it can always be used as the .,1 or cin6 input pin. p65/ftid/ .,1 / p65ddr 0 1 cin5 pin function p65 input pin p65 output pin ftid input pin, .,1 input pin, cin5 input pin this pin can always be used as the ftid, .,1 , or cin5 input pin.
229 table 8.14 port 6 pin functions (cont) pin selection method and pin functions p64/ftic/ .,1 / cin4/clampo the pin function is switched as shown below according to the combination of bit cloe in tconro of the timer connection function and bit p64ddr. cloe 0 1 p64ddr 0 1 pin function p64 input pin p64 output pin clampo output pin ftic input pin, .,1 input pin, cin4 input pin this pin can always be used as the ftic, .,1 , or cin4 input pin. p63/ftib/ .,1 / p63ddr 0 1 cin3/vfbacki pin function p63 input pin p63 output pin ftib input pin, vfbacki input pin, .,1 input pin, cin3 input pin this pin can always be used as the ftib, .,1 , cin3, or vfbacki input pin. p62/ftia/tmiy/ p62ddr 0 1 .,1 /cin2/ pin function p62 input pin p62 output pin vsynci ftia input pin, vsynci input pin, tmiy input pin, .,1 input pin, cin2 input pin this pin can always be used as the ftia, tmiy, .,1 , cin2, or vsynci input pin. p61/ftoa/ .,1 / cin1/vsynco the pin function is switched as shown below according to the combination of bit oea in tocr of the frt, bit voe in tconro of the timer connection function, and bit p61ddr. voe 0 1 oea 0 1 0 p61ddr 0 1 pin function p61 input pin p61 output pin ftoa output pin vsynco output pin .,1 input pin, cin1 input pin when this pin is used as the vsynco pin, bit oea in tocr of the frt must be cleared to 0. this pin can always be used as the .,1 or cin1 input pin.
230 table 8.14 port 6 pin functions (cont) pin selection method and pin functions p60/ftci/tmix/ p60ddr 0 1 .,1 /cin0/ pin function p60 input pin p60 output pin hfbacki ftci input pin, hfbacki input pin, tmix input pin, .,1 input pin, cin0 input pin this pin is used as the ftci input pin when an external clock is selected with bits cks1 and cks0 in tcr of the frt. it can always be used as the tmix, .,1 , cin0, or hfbacki input pin. 8.7.4 mos input pull-up function port 6 has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in any operating mode, and can be specified as on or off on a bit-by-bit basis. when a p6ddr bit is cleared to 0, setting the corresponding kmpcr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up current specification can be changed by means of the p6pue bit. when a pin is designated as an on-chip supporting module output pin, the mos input pull-up is always off. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.15 summarizes the mos input pull-up states. table 8.15 mos input pull-up states (port 6) mode reset hardware standby mode software standby mode in other operations 1, 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when p6ddr = 0 and kmpcr = 1; otherwise off.
231 8.8 port 7 8.8.1 overview port 7 is an 8-bit input port. port 7 pins also function as the a/d converter analog input pins (an0 to an7) and d/a converter analog output pins (da0, da1). port 7 functions are the same in all operating modes. figure 8.15 shows the port 7 pin configuration. p77 (input)/an7 (input)/da1 (output) p76 (input)/an6 (input)/da0 (output) p75 (input)/an5 (input) p74 (input)/an4 (input) p73 (input)/an3 (input) p72 (input)/an2 (input) p71 (input)/an1 (input) p70 (input)/an0 (input) port 7 port 7 pins figure 8.15 port 7 pin functions
232 8.8.2 register configuration table 8.16 shows the port 7 register configuration. port 7 is an input-only port, and does not have a data direction register or data register. table 8.16 port 7 registers name abbreviation r/w initial value address * 1 port 7 input data register p7pin r undefined h'ffbe* 2 notes: 1. lower 16 bits of the address. 2. p7pin has the same address as pbddr. port 7 input data register (p7pin) 7 p77pin * r 6 p76pin * r 5 p75pin * r 4 p74pin * r 3 p73pin * r 0 p70pin * r 2 p72pin * r 1 p71pin * r bit initial value read/write note: * determined by the state of pins p77 to p70. when a p7pin read is performed, the pin states are always read. p7pin has the same address as pbddr; if a write is performed, data will be written into pbddr and the port b setting will be changed. 8.8.3 pin functions port 7 pins also function as the a/d converter analog input pins (an0 to an7) and d/a converter analog output pins (da0, da1).
233 8.9 port 8 8.9.1 overview port 8 is an 8-bit i/o port. port 8 pins also function as sci1 i/o pins (txd1, rxd1, sck1), the iic1 i/o pin (scl1) (option in h8s/2148 series only), hif i/o pins ( &6 , ga20, ha0, hifsd) (h8s/2148 series only), and external interrupt input pins ( ,54 to ,54 ). port 8 pin functions are the same in all operating modes. figure 8.16 shows the port 8 pin configuration. p86 (i/o)/ irq5 (input)/sck1 (i/o)/scl1 (i/o) p85 (i/o)/ irq4 (input)/rxd1 (input) p84 (i/o)/ irq3 (input)/txd1 (output) p83 (i/o) p82 (i/o)/hifsd (input) p81 (i/o)/ cs2 (input)/ga20 (output) p80 (i/o)/ha0 (input) port 8 port 8 pins figure 8.16 port 8 pin functions
234 8.9.2 register configuration table 8.17 summarizes the port 8 registers. table 8.17 port 8 registers name abbreviation r/w initial value address * 1 port 8 data direction register p8ddr w h'80 h'ffbd * 2 port 8 data register p8dr r/w h'80 h'ffbf notes: 1. lower 16 bits of the address. 2. p8ddr has the same address as pbpin. port 8 data direction register (p8ddr) bit 76543210 p86ddr p85ddr p84ddr p83ddr p82ddr p81ddr p80ddr initial value 1 0 0 0 0 0 0 0 read/write w w w w w w w p8ddr is a 7-bit write-only register, the individual bits of which specify input or output for the pins of port 8. p8ddr has the same address as pbpin, and if read, the port b state will be returned. setting a p8ddr bit to 1 makes the corresponding port 8 pin an output pin, while clearing the bit to 0 makes the pin an input pin. p8ddr is initialized to h'80 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 8 data register (p8dr) bit 76543210 p86dr p85dr p84dr p83dr p82dr p81dr p80dr initial value 1 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w p8dr is a 7-bit readable/writable register that stores output data for the port 8 pins (p86 to p80). if a port 8 read is performed while p8ddr bits are set to 1, the p8dr values are read directly, regardless of the actual pin states. if a port 8 read is performed while p8ddr bits are cleared to 0, the pin states are read.
235 p8dr is initialized to h'80 by a reset and in hardware standby mode. it retains its prior state in software standby mode. 8.9.3 pin functions port 8 pins also function as sci1 i/o pins (txd1, rxd1, sck1), the iic1 i/o pin (scl1), hif i/o pins ( &6 , ga20, ha0, hifsd), and external interrupt input pins ( ,54 to ,54 ). the port 8 pin functions are shown in table 8.18. table 8.18 port 8 pin functions pin selection method and pin functions p86/ ,54 /sck1/ scl1 the pin function is switched as shown below according to the combination of bits cke1 and cke0 in scr of sci1, bit c/ $ in smr of sci1, bit ice in iccr of iic1, and bit p86ddr. ice 0 1 cke1 0 1 0 c/ $ 010 cke0 0 1 0 p86ddr 0 1 pin function p86 input pin p86 output pin sck1 output pin sck1 output pin sck1 input pin scl1 i/o pin ,54 input pin when the irq5e bit in ier is set to 1, this pin is used as the ,54 input pin. when this pin is used as the scl1 i/o pin, bits cke1 and cke0 in scr of sci1 and bit c/ $ in smr of sci1 must all be cleared to 0. scl1 is an nmos-only output, and has direct bus drive capability. p85/ ,54 /rxd1 the pin function is switched as shown below according to the combination of bit re in scr of sci1 and bit p85ddr. re 0 1 p85ddr 0 1 pin function p85 input pin p85 output pin rxd1 input pin ,54 input pin when the irq4e bit in ier is set to 1, this pin is used as the ,54 input pin. p84/ ,54 /txd1 the pin function is switched as shown below according to the combination of bit te in scr of sci1 and bit p84ddr. te 0 1 p84ddr 0 1 pin function p84 input pin p84 output pin txd1 output pin ,54 input pin when the irq3e bit in ier is set to 1, this pin is used as the ,54 input pin.
236 table 8.18 port 8 pin functions (cont) pin selection method and pin functions p83 the pin function is switched as shown below according to bit p83ddr. p83ddr 0 1 pin function p83 input pin p83 output pin p82/hifsd the pin function is switched as shown below according to the combination of operating mode, bit sde in syscr2, and bit p82ddr. operating mode not slave mode slave mode sde 0 1 p82ddr 0 1 0 1 pin function p82 input pin p82 output pin p82 input pin p82 output pin hifsd input pin p81/ga20/ &6 the pin function is switched as shown below according to the combination of operating mode, bit cs2e, bit fga20e in hicr of the hif, and bit p81ddr. operating mode not slave mode slave mode fga20e 0 1 cs2e 0 1 p81ddr 010101 pin function p81 input pin p81 output pin p81 input pin p81 output pin &6 input pin p81 input pin ga20 output pin this pin should be used as the ga20 or &6 output pin only in mode 2 or 3 (expe = 0). p80/ha0 the pin function is switched as shown below according to the combination of operating mode and bit p80ddr. operating mode not slave mode slave mode p80ddr 0 1 pin function p80 input pin p80 output pin ha0 input pin
237 8.10 port 9 8.10.1 overview port 9 is an 8-bit i/o port. port 9 pins also function as external interrupt input pins ( ,54 to ,54 ), the a/d converter external trigger input pin ( $'75* ), host interface input pins ( (&6 , &6 , ,2: , ,25 ) (h8s/2148 series only), the iic0 i/o pin (sda0) (option in h8s/2148 series only), the subclock input pin (excl), bus control signal i/o pins ( $6 / ,26 , 5' , +:5 , /:5 , :$,7 ), and the system clock (?) output pin. p97 is an nmos push-pull output. sda0 is an nmos open-drain output, and has direct bus drive capability. figure 8.17 shows the port 9 pin configuration. p97/ wait /sda0 p96/?excl p95/ as / ios / cs1 p94/ hwr / iow p93/ rd / ior p92/ irq0 p91/ irq1 p90/ lwr / irq2 / adtrg / ecs2 port 9 port 9 pins wait (input)/p97 (i/o)/sda0 (i/o) ?(output)/p96 (input)/excl (input) as (output)/ ios (output) hwr (output) rd (output) p92 (i/o)/ irq0 (input) p91 (i/o)/ irq1 (input) p90 (i/o)/ lwr (output)/ irq2 (input)/ adtrg (input) pin functions in modes 1, 2 and 3 (expe = 1) p97 (i/o)/sda0 (i/o) p96 (input)/?(output)/excl (input) p95 (i/o)/ cs1 (input) p94 (i/o)/ iow (input) p93 (i/o)/ ior (input) p92 (i/o)/ irq0 (input) p91 (i/o)/ irq1 (input) p90 (i/o)/ irq2 (input)/ adtrg (input)/ ecs2 (input) pin functions in modes 2 and 3 (expe = 0) figure 8.17 port 9 pin functions
238 8.10.2 register configuration table 8.19 summarizes the port 9 registers. table 8.19 port 9 registers name abbreviation r/w initial value address * 1 port 9 data direction register p9ddr w h'40/h'00 * 2 h'ffc0 port 9 data register p9dr r/w h'00 h'ffc1 notes: 1. lower 16 bits of the address. 2. initial value depends on the mode. port 9 data direction register (p9ddr) bit 76543210 p97ddr p96ddr p95ddr p94ddr p93ddr p92ddr p91ddr p90ddr mode 1 initial value 0 1 0 0 0 0 0 0 read/write w w w w w w w w modes 2 and 3 initial value 0 0 0 0 0 0 0 0 read/write w w w w w w w w p9ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 9. p9ddr cannot be read; if it is, an undefined value will be returned. p9ddr is initialized to h'40 (mode 1) or h'00 (modes 2 and 3) by a reset and in hardware standby mode. it retains its prior state in software standby mode. modes 1, 2, and 3 (expe = 1) pin p97 functions as a bus control input ( :$,7 ), the iic0 i/o pin (sda0), or an i/o port, according to the wait mode setting. when p97 functions as an i/o port, it becomes an output port when p97ddr is set to 1, and an input port when p97ddr is cleared to 0. pin p96 functions as the ? output pin when p96ddr is set to 1, and as the subclock input (excl) or an input port when p96ddr is cleared to 0. pins p95 to p93 automatically become bus control outputs ( $6 / ,26 , +:5 , 5' ), regardless of the input/output direction indicated by p95ddr to p93ddr. pins p92 and p91 become output ports when p92ddr and p91ddr are set to 1, and input ports when p92ddr and p91ddr are cleared to 0.
239 when the abw bit in wscr is cleared to 0, pin p90 becomes a bus control output ( /:5 ), regardless of the input/output direction indicated by p90ddr. when the abw bit is 1, pin p90 becomes an output port if p90ddr is set to 1, and an input port if p90ddr is cleared to 0. modes 2 and 3 (expe = 0) when the corresponding p9ddr bits are set to 1, pin p96 functions as the ? output pin and pins p97 and p95 to p90 become output ports. when p9ddr bits are cleared to 0, the corresponding pins become input ports. port 9 data register (p9dr) bit 76543210 p97dr p96dr p95dr p94dr p93dr p92dr p91dr p90dr initial value 0 * 000000 read/write r/w r r/w r/w r/w r/w r/w r/w note: * determined by the state of pin p96. p9dr is an 8-bit readable/writable register that stores output data for the port 9 pins (p97 to p90). with the exception of p96, if a port 9 read is performed while p9ddr bits are set to 1, the p9dr values are read directly, regardless of the actual pin states. if a port 9 read is performed while p9ddr bits are cleared to 0, the pin states are read. p9dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
240 8.10.3 pin functions port 9 pins also function as external interrupt input pins ( ,54 to ,54 ), the a/d converter trigger input pin ( $'75* ), hif input pins ( (&6 , &6 , ,2: , ,25 ), the iic0 i/o pin (sda0), the subclock input pin (excl), bus control signal i/o pins ( $6 / ,26 , 5' , +:5 , /:5 , :$,7 ), and the system clock (?) output pin. the pin functions differ between the mode 1, 2, and 3 (expe = 1) expanded modes and the mode 2 and 3 (expe = 0) single-chip modes. the port 9 pin functions are shown in table 8.20. table 8.20 port 9 pin functions pin selection method and pin functions p97/ :$,7 /sda0 the pin function is switched as shown below according to the combination of operating mode, bit wms1 in wscr, bit ice in iccr of iic0, and bit p97ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) wms1 0 1 ice 0 1 0 1 p97ddr 0 1 0 1 pin function p97 input pin p97 output pin sda0 i/o pin :$,7 input pin p97 input pin p97 output pin sda0 i/o pin when this pin is set as the p97 output pin, it is an nmos push-pull output. sda0 is an nmos open-drain output, and has direct bus drive capability. p96/?/excl the pin function is switched as shown below according to the combination of bit excle in lpwrcr and bit p96ddr. p96ddr 0 1 excle 0 1 0 pin function p96 input pin excl input pin ? output pin when this pin is used as the excl input pin, p96ddr should be cleared to 0. p95/ $6 / ,26 / &6 the pin function is switched as shown below according to the combination of operating mode, bit iose in syscr, bit hi12e in syscr2, and bit p95ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e 0 1 p95ddr 0 1 iose 0 1 pin function $6 output pin ,26 output pin p95 input pin p95 output pin &6 input pin
241 table 8.20 port 9 pin functions (cont) pin selection method and pin functions p94/ +:5 / ,2: the pin function is switched as shown below according to the combination of operating mode, bit hi12e in syscr2, and bit p94ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e 0 1 p94ddr 0 1 pin function +:5 output pin p94 input pin p94 output pin ,2: input pin p93/ 5' / ,25 the pin function is switched as shown below according to the combination of operating mode, bit hi12e in syscr2, and bit p93ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e 0 1 p93ddr 0 1 pin function 5' output pin p93 input pin p93 output pin ,25 input pin p92/ ,54 p92ddr 0 1 pin function p92 input pin p92 output pin ,54 input pin when bit irq0e in ier is set to 1, this pin is used as the ,54 input pin. p91/ ,54 p91ddr 0 1 pin function p91 input pin p91 output pin ,54 input pin when bit irq1e in ier is set to 1, this pin is used as the ,54 input pin.
242 table 8.20 port 9 pin functions (cont) pin selection method and pin functions p90/ /:5 / ,54 / $'75* / (&6 the pin function is switched as shown below according to the combination of operating mode, bit abw in wscr, bits hi12e and cs2e in syscr2, bit fga20e in hicr, and bit p90ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 hi12e any one 0 1 fga20e 1 cs2e 1 p90ddr 0101 pin function /:5 output pin p90 input pin p90 output pin p90 input pin p90 output pin (&6 input pin ,54 input pin, $'75* input pin when the irq2e bit in ier is set to 1 in mode 1, 2, or 3 (expe = 1) with the abw bit in wscr set to 1, or in mode 2 and 3 (expe = 0), this pin is used as the ,54 input pin. when trgs1 and trgs0 in adcr of the a/d converter are both set to 1, this pin is used as the $'75* input pin.
243 8.11 port a 8.11.1 overview port a is an 8-bit i/o port. port a pins also function as keyboard buffer controller i/o pins (ps2ac, ps2ad, ps2bc, ps2bd, ps2cc, ps2cd) (h8s/2148 series only), key-sense interrupt input pins ( .,1 to .,1 ), expansion a/d converter input pins (cin15 to cin8), and address output pins (a23 to a16). port a pin functions are the same in all operating modes. figure 8.18 shows the port a pin configuration. pa7/a23/ kin15 /cin15/ps2cd pa6/a22/ kin14 /cin14/ps2cc pa5/a21/ kin13 /cin13/ps2bd pa4/a20/ kin12 /cin12/ps2bc pa3/a19/ kin11 /cin11/ps2ad pa2/a18/ kin10 /cin10/ps2ac pa1/a17/ kin9 /cin9 pa0/a16/ kin8 /cin8 port a port a pins pa7 (i/o)/ kin15 (input)/cin15 (input)/ps2cd (i/o) pa6 (i/o)/ kin14 (input)/cin14 (input)/ps2cc (i/o) pa5 (i/o)/ kin13 (input)/cin13 (input)/ps2bd (i/o) pa4 (i/o)/ kin12 (input)/cin12 (input)/ps2bc (i/o) pa3 (i/o)/ kin11 (input)/cin11 (input)/ps2ad (i/o) pa2 (i/o)/ kin10 (input)/cin10 (input)/ps2ac (i/o) pa1 (i/o)/ kin9 (input)/cin9 (input) pa0 (i/o)/ kin8 (input)/cin8 (input) pin functions in modes 1 and 2 (expe = 0) and mode 3 pa7 (i/o)/a23 (output)/ kin15 (input)/cin15 (input)/ps2cd (i/o) pa6 (i/o)/a22 (output)/ kin14 (input)/cin14 (input)/ps2cc (i/o) pa5 (i/o)/a21 (output)/ kin13 (input)/cin13 (input)/ps2bd (i/o) pa4 (i/o)/a20 (output)/ kin12 (input)/cin12 (input)/ps2bc (i/o) pa3 (i/o)/a19 (output)/ kin11 (input)/cin11 (input)/ps2ad (i/o) pa2 (i/o)/a18 (output)/ kin10 (input)/cin10 (input)/ps2ac (i/o) pa1 (i/o)/a17 (output)/ kin9 (input)/cin9 (input) pa0 (i/o)/a16 (output)/ kin8 (input)/cin8 (input) pin functions in mode 2 (expe = 1) figure 8.18 port a pin functions
244 8.11.2 register configuration table 8.21 summarizes the port a registers. table 8.21 port a registers name abbreviation r/w initial value address * 1 port a data direction register paddr w h'00 h'ffab * 2 port a output data register paodr r/w h'00 h'ffaa port a input data register papin r undefined h'ffab * 2 notes: 1. lower 16 bits of the address. 2. paddr and papin have the same address. port a data direction register (paddr) bit 76543210 pa7ddr pa6ddr pa5ddr pa4ddr pa3ddr pa2ddr pa1ddr pa0ddr initial value 0 0 0 0 0 0 0 0 read/write w w w w w w w w paddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port a. setting a paddr bit to 1 makes the corresponding port a pin an output pin, while clearing the bit to 0 makes the pin an input pin. paddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port a output data register (paodr) bit 76543210 pa7odr pa6odr pa5odr pa4odr pa3odr pa2odr pa1odr pa0odr initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w paodr is an 8-bit readable/writable register that stores output data for the port a pins (pa7 to pa0). paodr can always be read or written to, regardless of the contents of paddr. paodr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
245 port a input data register (papin) bit 76543210 pa7pin pa6pin pa5pin pa4pin pa3pin pa2pin pa1pin pa0pin initial value * * * * * * * * read/write r r r r r r r r note: * determined by the state of pins pa7 to pa0. reading papin always returns the pin states. 8.11.3 pin functions port a pins also function as keyboard buffer controller i/o pins (ps2ac, ps2ad, ps2bc, ps2bd, ps2cc, ps2cd), key-sense interrupt input pins ( .,1 to .,1 ), expansion a/d converter input pins (cin15 to cin8), and address output pins (a23 to a16). the port a pin functions are shown in table 8.22. table 8.22 port a pin functions pin selection method and pin functions pa7/a23/ps2cd/ .,1 /cin15 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr2h of the keyboard buffer controller, the iose bit in syscr, and bit pa7ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa7ddr 0 1 0 1 iose 0 1 pin function pa7 input pin pa7 output pin ps2cd output pin pa7 input pin a23 output pin pa7 output pin ps2cd output pin .,1 input pin, cin15 input pin, ps2cd input pin when the iics bit in stcr is set to 1, this pin functions as a bus buffer. this pin can always be used as the ps2cd, .,1 , or cin15 input pin.
246 table 8.22 port a pin functions (cont) pin selection method and pin functions pa6/a22/ps2cc/ .,1 /cin14 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr2h of the keyboard buffer controller, the iose bit in syscr, and bit pa6ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa6ddr 0 1 0 1 iose 0 1 pin function pa6 input pin pa6 output pin ps2cc output pin pa6 input pin a22 output pin pa6 output pin ps2cc output pin .,1 input pin, cin14 input pin, ps2cc input pin when the iics bit in stcr is set to 1, this pin functions as a bus buffer. this pin can always be used as the ps2cc, .,1 , or cin14 input pin. pa5/a21/ps2bd/ .,1 /cin13 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr1h of the keyboard buffer controller, the iose bit in syscr, and bit pa5ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa5ddr 0 1 0 1 iose 0 1 pin function pa5 input pin pa5 output pin ps2bd output pin pa5 input pin a21 output pin pa5 output pin ps2bd output pin .,1 input pin, cin13 input pin, ps2bd input pin when the iics bit in stcr is set to 1, this pin functions as a bus buffer. this pin can always be used as the ps2bd, .,1 , or cin13 input pin.
247 table 8.22 port a pin functions (cont) pin selection method and pin functions pa4/a20/ps2bc/ .,1 /cin12 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr1h of the keyboard buffer controller, the iose bit in syscr, and bit pa4ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa4ddr 0 1 0 1 iose 0 1 pin function pa4 input pin pa4 output pin ps2bc output pin pa4 input pin a20 output pin pa4 output pin ps2bc output pin .,1 input pin, cin12 input pin, ps2bc input pin when the iics bit in stcr is set to 1, this pin functions as a bus buffer. this pin can always be used as the ps2bc, .,1 , or cin12 input pin. pa3/a19/ps2ad/ .,1 /cin11 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr0h of the keyboard buffer controller, the iose bit in syscr, and bit pa3ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa3ddr 0 1 0 1 iose 0 1 pin function pa3 input pin pa3 output pin ps2ad output pin pa3 input pin a19 output pin pa3 output pin ps2ad output pin .,1 input pin, cin11 input pin, ps2ad input pin this pin can always be used as the ps2ad, .,1 , or cin11 input pin.
248 table 8.22 port a pin functions (cont) pin selection method and pin functions pa2/a18/ps2ac/ .,1 /cin10 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr0h of the keyboard buffer controller, the iose bit in syscr, and bit pa2ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa2ddr 0 1 0 1 iose 0 1 pin function pa2 input pin pa2 output pin ps2ac output pin pa2 input pin a18 output pin pa2 output pin ps2ac output pin .,1 input pin, cin10 input pin, ps2ac input pin this pin can always be used as the ps2ac, .,1 , or cin10 input pin. pa1/a17/ .,1 / cin9 the pin function is switched as shown below according to the combination of the iose bit in syscr and bit pa1ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) pa1ddr 0 1 0 1 iose 0 1 pin function pa1 input pin pa1 output pin pa1 input pin a17 output pin pa1 output pin .,1 input pin, cin9 input pin this pin can always be used as the .,1 or cin9 input pin. pa0/a16/ .,1 / cin8 the pin function is switched as shown below according to the combination of the iose bit in syscr and bit pa0ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) pa0ddr 0 1 0 1 iose 0 1 pin function pa0 input pin pa0 output pin pa0 input pin a16 output pin pa0 output pin .,1 input pin, cin8 input pin this pin can always be used as the .,1 or cin8 input pin.
249 8.11.4 mos input pull-up function port a has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in any operating mode, and can be specified as on or off on a bit-by-bit basis. when a paddr bit is cleared to 0, setting the corresponding paodr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up for pins pa7 to pa4 is always off when iics is set to 1. when the keyboard buffer control pin function is selected for pins pa7 to pa2, the mos input pull-up is always off. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.23 summarizes the mos input pull-up states. table 8.23 mos input pull-up states (port a) mode reset hardware standby mode software standby mode in other operations 1, 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when paddr = 0 and paodr = 1; otherwise off.
250 8.12 port b 8.12.1 overview port b is an 8-bit i/o port. port b pins also have hif input/output pins ( &6 , &6 , hirq3, hirq4) (h8s/2148 series only), and a data bus input/output function (as d7 to d0). the pin functions depend on the operating mode. figure 8.19 shows the port b pin configuration. pb7/d7 pb6/d6 pb5/d5 pb4/d4 pb3/d3/ cs4 pb2/d2/ cs3 pb1/d1/hirq4 pb0/d0/hirq3 port b port b pins d7 (i/o) d6 (i/o) d5 (i/o) d4 (i/o) d3 (i/o) d2 (i/o) d1 (i/o) d0 (i/o) modes 1, 2, and 3 (expe = 1) when abw = 0 pb7 (i/o) pb6 (i/o) pb5 (i/o) pb4 (i/o) pb3 (i/o)/ cs4 (input) pb2 (i/o)/ cs3 (input) pb1 (i/o)/hirq4 (output) pb0 (i/o)/hirq3 (output) modes 1, 2, and 3 (expe = 1) when abw = 1, and modes 1, 2, and 3 (expe = 0) figure 8.19 port b pin functions
251 8.12.2 register configuration table 8.24 summarizes the port b registers. table 8.24 port b registers name abbreviation r/w initial value address * 1 port b data direction register pbddr w h'00 h'ffbe * 2 port b output data register pbodr r/w h'00 h'ffbc port b input data register pbpin r undefined h'ffbd * 3 notes: 1. lower 16 bits of the address. 2. pbddr has the same address as p7pin. 3. pbpin has the same address as p8ddr. port b data direction register (pbddr) bit 76543210 pb7ddr pb6ddr pb5ddr pb4ddr pb3ddr pb2ddr pb1ddr pb0ddr initial value 0 0 0 0 0 0 0 0 read/write w w w w w w w w pbddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port b. pbddr has the same address as p7pin, and if read, the port 7 pin states will be returned. setting a pbddr bit to 1 makes the corresponding port b pin an output pin, while clearing the bit to 0 makes the pin an input pin. pbddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. modes 1, 2, and 3 (expe = 1) when the abw bit in wscr is cleared to 0, port b pins automatically become data i/o pins (d7 to d0), regardless of the input/output direction indicated by pbddr. when the abw bit is 1, a port b pin becomes an output port if the corresponding pbddr bit is set to 1, and an input port if the bit is cleared to 0. data i/o pins go to the high-impedance state after a reset, and in hardware standby mode or software standby mode. modes 2 and 3 (expe = 0) a port b pin becomes an output port if the corresponding pbddr bit is set to 1, and an input port if the bit is cleared to 0.
252 port b output data register (pbodr) bit 76543210 pb7odr pb6odr pb5odr pb4odr pb3odr pb2odr pb1odr pb0odr initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w pbodr is an 8-bit readable/writable register that stores output data for the port b pins (pb7 to pb0). pbodr can always be read or written to, regardless of the contents of pbddr. pbodr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port b input data register (pbpin) bit 76543210 pb7pin pb6pin pb5pin pb4pin pb3pin pb2pin pb1pin pb0pin initial value * * * * * * * * read/write r r r r r r r r note: * determined by the state of pins pb7 to pb0. reading pbpin always returns the pin states. pbpin has the same address as p8ddr. if a write is performed, data will be written to p8ddr and the port 8 settings will change.
253 8.12.3 pin functions port b pins also function as hif input pins ( &6 , &6 , hirq3, hirq4) [h8s/2148 series only] and data bus i/o pins (d7 to d0). the port b pin functions are shown in table 8.25. table 8.25 port b pin functions pin selection method and pin functions pb7/d7 the pin function is switched as shown below according to the combination of the operating mode, bit pb7ddr, and bit abw in wscr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 pb7ddr 0 1 0 1 pin function d7 i/o pin pb7 input pin pb7 output pin pb7 input pin pb7 output pin pb6/d6 the pin function is switched as shown below according to the combination of the operating mode, bit pb6ddr, and bit abw in wscr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 pb6ddr 0 1 0 1 pin function d6 i/o pin pb6 input pin pb6 output pin pb6 input pin pb6 output pin pb5/d5 the pin function is switched as shown below according to the combination of the operating mode, bit pb5ddr, and bit abw in wscr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 pb5ddr 0 1 0 1 pin function d5 i/o pin pb5 input pin pb5 output pin pb5 input pin pb5 output pin
254 table 8.25 port b pin functions (cont) pin selection method and pin functions pb4/d4 the pin function is switched as shown below according to the combination of the operating mode, bit pb4ddr, and bit abw in wscr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 pb4ddr 0 1 0 1 pin function d4 i/o pin pb4 input pin pb4 output pin pb4 input pin pb4 output pin pb3/d3/ &6 the pin function is switched as shown below according to the combination of the operating mode, bits hi12e and cs4e in syscr2, bit abw in wscr, and bit pb3ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e either cleared to 0 1 cs4e 1 abw 0 1 pb3ddr 0 1 0 1 pin function d3 i/o pin pb3 input pin pb3 output pin pb3 input pin pb3 output pin &6 input pin pb2/d2/ &6 the pin function is switched as shown below according to the combination of the operating mode, bits hi12e and cs3e in syscr2, bit abw in wscr, and bit pb2ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e either cleared to 0 1 cs3e 1 abw 0 1 pb2ddr 0 1 0 1 pin function d2 i/o pin pb2 input pin pb2 output pin pb2 input pin pb2 output pin &6 input pin
255 table 8.25 port b pin functions (cont) pin selection method and pin functions pb1/d1/hirq4 the pin function is switched as shown below according to the combination of the operating mode, bits hi12e and cs4e in syscr2, bit abw in wscr, and bit pb1ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e either cleared to 0 1 cs4e 1 abw 0 1 pb1ddr 0 1 0 1 pin function d1 i/o pin pb1 input pin pb1 output pin pb1 input pin pb1 output pin hirq4 output pin pb0/d0/hirq3 the pin function is switched as shown below according to the combination of the operating mode, bits hi12e and cs3e in syscr2, bit abw in wscr, and bit pb0ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e either cleared to 0 1 cs3e 1 abw 0 1 pb0ddr 0 1 0 1 pin function d0 i/o pin pb0 input pin pb0 output pin pb0 input pin pb0 output pin hirq3 output pin
256 8.12.4 mos input pull-up function port b has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in modes 1, 2, and 3 (expe = 1) with the abw bit in wscr set to 1, and in modes 2 and 3 (expe = 0), and can be specified as on or off on a bit-by-bit basis. when a pbddr bit is cleared to 0, setting the corresponding pbodr bit to 1 turns on the mos input pull-up for that pin. when a pin is designated as an on-chip supporting module output pin, the mos input pull-up is always off. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.25 summarizes the mos input pull-up states. table 8.25 mos input pull-up states (port b) mode reset hardware standby mode software standby mode in other operations 1, 2, 3 (expe = 1) with abw in wscr = 0 off off off off 1, 2, 3 (expe = 1) with abw in wscr = 1, and 2, 3 (expe = 0) on/off on/off legend: off: mos input pull-up is always off. on/off: on when pbddr = 0 and pbodr = 1; otherwise off.
257 section 9 8-bit pwm timers [h8s/2148 series] 9.1 overview the h8/2148 series has an on-chip pulse width modulation (pwm) timer module with sixteen outputs. sixteen output waveforms are generated from a common time base, enabling pwm output with a high carrier frequency to be produced using pulse division. the pwm timer module has sixteen 8-bit pwm data registers (pwdrs), and an output pulse with a duty cycle of 0 to 100% can be obtained as specified by pwdr and the port data register (p1dr or p2dr). 9.1.1 features the pwm timer module has the following features. operable at a maximum carrier frequency of 1.25 mhz using pulse division (at 20 mhz operation) duty cycles from 0 to 100% with 1/256 resolution (100% duty realized by port output) direct or inverted pwm output, and pwm output enable/disable control
258 9.1.2 block diagram figure 9.1 shows a block diagram of the pwm timer module. pwdr0 pwdr1 pwdr2 pwdr3 pwdr4 pwdr5 pwdr6 pwdr7 pwdr8 pwdr9 pwdr10 pwdr11 pwdr12 pwdr13 pwdr14 pwdr15 p10/pw0 p11/pw1 p12/pw2 p13/pw3 p14/pw4 p15/pw5 p16/pw6 p17/pw7 p20/pw8 p21/pw9 p22/pw10 p23/pw11 p24/pw12 p25/pw13 p26/pw14 p27/pw15 port/pwm output control comparator 0 comparator 1 comparator 2 comparator 3 comparator 4 comparator 5 comparator 6 comparator 7 comparator 8 comparator 9 comparator 10 comparator 11 comparator 12 comparator 13 comparator 14 comparator 15 pwdprb pwoerb p2ddr p2dr pwdpra pwoera p1ddr p1dr module data bus bus interface internal data bus pwsl clock selection ? internal clock ?2 legend: pwsl: pwdr: pwdpra: pwdprb: pwoera: pwoerb: pcsr: p1ddr: p2ddr: p1dr: p2dr: pwm register select pwm data register pwm data polarity register a pwm data polarity register b pwm output enable register a pwm output enable register b peripheral clock select register port 1 data direction register port 2 data direction register port 1 data register port 2 data register tcnt pcsr ?4 ?8 ?16 figure 9.1 block diagram of pwm timer module
259 9.1.3 pin configuration table 9.1 shows the pwm output pin. table 9.1 pin configuration name abbreviation i/o function pwm output pin 0 to 15 pw0 to pw15 output pwm timer pulse output 0 to 15 9.1.4 register configuration table 9.2 lists the registers of the pwm timer module. table 9.2 pwm timer module registers name abbreviation r/w initial value address * pwm register select pwsl r/w h'20 h'ffd6 pwm data registers 0 to 15 pwdr0 to pwdr15 r/w h'00 h'ffd7 pwm data polarity register a pwdpra r/w h'00 h'ffd5 pwm data polarity register b pwdprb r/w h'00 h'ffd4 pwm output enable register a pwoera r/w h'00 h'ffd3 pwm output enable register b pwoerb r/w h'00 h'ffd2 port 1 data direction register p1ddr w h'00 h'ffb0 port 2 data direction register p2ddr w h'00 h'ffb1 port 1 data register p1dr r/w h'00 h'ffb2 port 2 data register p2dr r/w h'00 h'ffb3 peripheral clock select register pcsr r/w h'00 h'ff82 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 note: * lower 16 bits of the address.
260 9.2 register descriptions 9.2.1 pwm register select (pwsl) bit initial value read/write 7 pwcke 0 r/w 6 pwcks 0 r/w 5 ? 1 4 ? 0 3 rs3 0 r/w 0 rs0 0 r/w 2 rs2 0 r/w 1 rs1 0 r/w pwsl is an 8-bit readable/writable register used to select the pwm timer input clock and the pwm data register. pwsl is initialized to h'20 by a reset, and in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode. bits 7 and 6pwm clock enable, pwm clock select (pwcke, pwcks): these bits, together with bits pwcka and pwckb in pcsr, select the internal clock input to tcnt in the pwm timer. pwsl pcsr bit 7 bit 6 bit 2 bit 1 pwcke pwcks pwckb pwcka description 0 clock input is disabled (initial value) 1 0 ? (system clock) is selected 1 0 0 ?/2 is selected 1 ?/4 is selected 1 0 ?/8 is selected 1 ?/16 is selected the pwm resolution, pwm conversion period, and carrier frequency depend on the selected internal clock, and can be found from the following equations. resolution (minimum pulse width) = 1/internal clock frequency pwm conversion period = resolution 256 carrier frequency = 16/pwm conversion period thus, with a 20 mhz system clock (?), the resolution, pwm conversion period, and carrier frequency are as shown below.
261 table 9.3 resolution, pwm conversion period, and carrier frequency when ? = 20 mhz internal clock frequency resolution pwm conversion period carrier frequency ? 50 ns 12.8 m s 1250 khz ?/2 100 ns 25.6 m s 625 khz ?/4 200 ns 51.2 m s 312.5 khz ?/8 400 ns 102.4 m s 156.3 khz ?/16 800 ns 204.8 m s 78.1 khz bit 5reserved: this bit is always read as 1 and cannot be modified. bit 4reserved: this bit is always read as 0 and cannot be modified. bits 3 to 0register select (rs3 to rs0): these bits select the pwm data register. bit 3 bit 2 bit 1 bit 0 rs3 rs2 rs1 rs0 register selection 0 0 0 0 pwdr0 selected 1 pwdr1 selected 1 0 pwdr2 selected 1 pwdr3 selected 1 0 0 pwdr4 selected 1 pwdr5 selected 1 0 pwdr6 selected 1 pwdr7 selected 1 0 0 0 pwdr8 selected 1 pwdr9 selected 1 0 pwdr10 selected 1 pwdr11 selected 1 0 0 pwdr12 selected 1 pwdr13 selected 1 0 pwdr14 selected 1 pwdr15 selected
262 9.2.2 pwm data registers (pwdr0 to pwdr15) bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w each pwdr is an 8-bit readable/writable register that specifies the duty cycle of the basic pulse to be output, and the number of additional pulses. the value set in pwdr corresponds to a 0 or 1 ratio in the conversion period. the upper 4 bits specify the duty cycle of the basic pulse as 0/16 to 15/16 with a resolution of 1/16. the lower 4 bits specify how many extra pulses are to be added within the conversion period comprising 16 basic pulses. thus, a specification of 0/256 to 255/256 is possible for 0/1 ratios within the conversion period. for 256/256 (100%) output, port output should be used. pwdr is initialized to h'00 by a reset, and in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode.
263 9.2.3 pwm data polarity registers a and b (pwdpra and pwdprb) pwdpra bit initial value read/write 7 os7 0 r/w 6 os6 0 r/w 5 os5 0 r/w 4 os4 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w pwdprb bit initial value read/write 7 os15 0 r/w 6 os14 0 r/w 5 os13 0 r/w 4 os12 0 r/w 3 os11 0 r/w 0 os8 0 r/w 2 os10 0 r/w 1 os9 0 r/w each pwdpr is an 8-bit readable/writable register that controls the polarity of the pwm output. bits os0 to os15 correspond to outputs pw0 to pw15. pwdpr is initialized to h'00 by a reset and in hardware standby mode. os description 0 pwm direct output (pwdr value corresponds to high width of output) (initial value) 1 pwm inverted output (pwdr value corresponds to low width of output)
264 9.2.4 pwm output enable registers a and b (pwoera and pwoerb) pwoera bit initial value read/write 7 oe7 0 r/w 6 oe6 0 r/w 5 oe5 0 r/w 4 oe4 0 r/w 3 oe3 0 r/w 0 oe0 0 r/w 2 oe2 0 r/w 1 oe1 0 r/w pwoerb bit initial value read/write 7 oe15 0 r/w 6 oe14 0 r/w 5 oe13 0 r/w 4 oe12 0 r/w 3 oe11 0 r/w 0 oe8 0 r/w 2 oe10 0 r/w 1 oe9 0 r/w each pwoer is an 8-bit readable/writable register that switches between pwm output and port output. bits oe15 to oe0 correspond to outputs pw15 to pw0. to set a pin in the output state, a setting in the port direction register is also necessary. bits p17ddr to p10ddr correspond to outputs pw7 to pw0, and bits p27ddr to p20ddr correspond to outputs pw15 to pw8. pwoer is initialized to h'00 by a reset and in hardware standby mode. ddr oe description 0 0 port input (initial value) 1 port input 1 0 port output or pwm 256/256 output 1 pwm output (0 to 255/256 output)
265 9.2.5 peripheral clock select register (pcsr) bit initial value read/write 7 ? 0 6 ? 0 5 ? 0 4 ? 0 3 ? 0 0 ? 0 2 pwckb 0 r/w 1 pwcka 0 r/w pcsr is an 8-bit readable/writable register that selects the pwm timer input clock. pcsr is initialized to h'00 by a reset, and in hardware standby mode. bits 7 to 3reserved: these bits cannot be modified and are always read as 0. bits 2 and 1pwm clock select (pwckb, pwcka): together with bits pwcke and pwcks in pwsl, these bits select the internal clock input to tcnt in the pwm timer. for details, see section 9.2.1, pwm register select (pwsl). bit 0reserved: do not set this bit to 1.
266 9.2.6 port 1 data direction register (p1ddr) bit initial value read/write 7 p17ddr 0 w 6 p16ddr 0 w 5 p15ddr 0 w 4 p14ddr 0 w 3 p13ddr 0 w 0 p10ddr 0 w 2 p12ddr 0 w 1 p11ddr 0 w p1ddr is an 8-bit write-only register that specifies the input/output direction and pwm output for each pin of port 1 on a bit-by-bit basis. port 1 pins are multiplexed with pins pw0 to pw7. the bit corresponding to a pin to be used for pwm output should be set to 1. for details on p1ddr, see section 8.2, port 1.
267 9.2.7 port 2 data direction register (p2ddr) bit initial value read/write 7 p27ddr 0 w 6 p26ddr 0 w 5 p25ddr 0 w 4 p24ddr 0 w 3 p23ddr 0 w 0 p20ddr 0 w 2 p22ddr 0 w 1 p21ddr 0 w p2ddr is an 8-bit write-only register that specifies the input/output direction and pwm output for each pin of port j on a bit-by-bit basis. port 2 pins are multiplexed with pins pw8 to pw15. the bit corresponding to a pin to be used for pwm output should be set to 1. for details on p2ddr, see section 8.3, port 2.
268 9.2.8 port 1 data register (p1dr) bit initial value read/write 7 p17dr 0 r/w 6 p16dr 0 r/w 5 p15dr 0 r/w 4 p14dr 0 r/w 3 p13dr 0 r/w 0 p10dr 0 r/w 2 p12dr 0 r/w 1 p11dr 0 r/w p1dr is an 8-bit readable/writable register used to fix pwm output at 1 (when os = 0) or 0 (when os = 1). for details on p1dr, see section 8.2, port 1.
269 9.2.9 port 2 data register (p2dr) bit initial value read/write 7 p27dr 0 r/w 6 p26dr 0 r/w 5 p25dr 0 r/w 4 p24dr 0 r/w 3 p23dr 0 r/w 0 p20dr 0 r/w 2 p22dr 0 r/w 1 p21dr 0 r/w p2dr is an 8-bit readable/writable register used to fix pwm output at 1 (when os = 0) or 0 (when os = 1). for details on p2dr, see section 8.3, port 2.
270 9.2.10 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers, and is used to perform module stop mode control. when the mstp11 bit is set to 1, 8-bit pwm timer operation is halted and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 3module stop (mstp11): specifies pwm module stop mode. mstpcrh bit 3 mstp11 description 0 pwm module stop mode is cleared 1 pwm module stop mode is set (initial value)
271 9.3 operation 9.3.1 correspondence between pwm data register contents and output waveform the upper 4 bits of pwdr specify the duty cycle of the basic pulse as 0/16 to 15/16 with a resolution of 1/16, as shown in table 9.4. table 9.4 duty cycle of basic pulse 0123456789abc d ef0 000000 000001 000010 000011 000100 000101 000110 000111 111000 111001 111010 111011 111100 111101 111110 111111 upper 6 bits basic pulse waveform (internal) . . .
272 the lower 4 bits of pwdr specify the position of pulses added to the 16 basic pulses, as shown in table 9.5. an additional pulse consists of a high period (when os = 0) with a width equal to the resolution, added before the rising edge of a basic pulse. when the upper 4 bits of pwdr are 0000, there is no rising edge of the basic pulse, but the timing for adding pulses is the same. table 9.5 position of pulses added to basic pulses basic pulse no. lower 4 bits 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0000 0001 yes 0010 yes yes 0011 yes yes yes 0100 yes yes yes yes 0101 yes yes yes yes yes 0110 yes yes yes yes yes yes 0111 yes yes yes yes yes yes yes 1000 yes yes yes yes yes yes yes yes 1001 yes yes yes yes yes yes yes yes yes 1010 yes yes yes yes yes yes yes yes yes yes 1011 yes yes yes yes yes yes yes yes yes yes yes 1100 yes yes yes yes yes yes yes yes yes yes yes yes 1101 yes yes yes yes yes yes yes yes yes yes yes yes yes 1110 yes yes yes yes yes yes yes yes yes yes yes yes yes yes 1111 yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes additional pulse provided no additional pulse resolution width additional pulse figure 9.2 example of additional pulse timing (when upper 4 bits of pwdr = 1000)
273 section 10 14-bit pwm d/a 10.1 overview the h8s/2148 series and h8s/2144 series have an on-chip 14-bit pulse-width modulator (pwm) with two output channels. each channel can be connected to an external low-pass filter to operate as a 14-bit d/a converter. both channels share the same counter (dacnt) and control register (dacr). 10.1.1 features the features of the 14-bit pwm d/a are listed below. the pulse is subdivided into multiple base cycles to reduce ripple. two resolution settings and two base cycle settings are available the resolution can be set equal to one or two system clock cycles. the base cycle can be set equal to t 64 or t 256, where t is the resolution. four operating rates the two resolution settings and two base cycle settings combine to give a selection of four operating rates.
274 10.1.2 block diagram figure 10.1 shows a block diagram of the pwm d/a module. internal clock ?2 pwx0 pwx1 dadra dadrb dacnt dacr legend: dacr: pwm d/a control register ( 6 bits) dadra: pwm d/a data register a (15 bits) dadrb: pwm d/a data register b (15 bits) dacnt: pwm d/a counter (14 bits) control logic clock selection clock internal data bus basic cycle compare-match a fine-adjustment pulse addition a basic cycle compare-match b fine-adjustment pulse addition b basic cycle overflow comparator a comparator b bus interface module data bus figure 10.1 pwm d/a block diagram
275 10.1.3 pin configuration table 10.1 lists the pins used by the pwm d/a module. table 10.1 input and output pins channel name abbr. i/o function a pwm output pin 0 pwx0 output pwm output, channel a b pwm output pin 1 pwx1 output pwm output, channel b 10.1.4 register configuration table 10.2 lists the registers of the pwm d/a module. table 10.2 register configuration name abbreviation r/w initial value address * 1 pwm d/a control register dacr r/w h'30 h'ffa0 * 2 pwm d/a data register a high dadrah r/w h'ff h'ffa0 * 2 pwm d/a data register a low dadral r/w h'ff h'ffa1 * 2 pwm d/a data register b high dadrbh r/w h'ff h'ffa6 * 2 pwm d/a data register b low dadrbl r/w h'ff h'ffa7 * 2 pwm d/a counter high dacnth r/w h'00 h'ffa6 * 2 pwm d/a counter low dacntl r/w h'03 h'ffa7 * 2 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. the same addresses are shared by dadrah and dacr, and by dadrb and dacnt. switching is performed by the regs bit in dacnt or dadrb.
276 10.2 register descriptions 10.2.1 pwm d/a counter (dacnt) 15 7 0 r/w 14 6 0 r/w 13 5 0 r/w 12 4 0 r/w 11 3 0 r/w 8 0 0 r/w 10 2 0 r/w 9 1 0 r/w bit (cpu) bit (counter) initial value read/write 7 8 0 r/w 6 9 0 r/w 5 10 0 r/w 4 11 0 r/w 3 12 0 r/w 0 ? regs 1 r/w 2 13 0 r/w 1 ? ? 1 dacnth dacntl dacnt is a 14-bit readable/writable up-counter that increments on an input clock pulse. the input clock is selected by the clock select bit (cks) in dacr. the cpu can read and write the dacnt value, but since dacnt is a 16-bit register, data transfers between it and the cpu are performed using a temporary register (temp). see section 10.3, bus master interface, for details. dacnt functions as the time base for both pwm d/a channels. when a channel operates with 14-bit precision, it uses all dacnt bits. when a channel operates with 12-bit precision, it uses the lower 12 (counter) bits and ignores the upper two (counter) bits. dacnt is initialized to h'0003 by a reset, in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode, and by the pwme bit. bit 1 of dacntl (cpu) is not used, and is always read as 1. dacntl bit 0register select (regs): dadra and dacr, and dadrb and dacnt, are located at the same addresses. the regs bit specifies which registers can be accessed. the regs bit can be accessed regardless of whether dadrb or dacnt is selected. bit 0 regs description 0 dadra and dadrb can be accessed 1 dacr and dacnt can be accessed (initial value)
277 10.2.2 d/a data registers a and b (dadra and dadrb) 15? 13? da13? 1? r/w 14? 12? da12? 1? r/w 13? 11? da11? 1? r/w 12? 10? da10? 1? r/w 11? 9? da9? 1? r/w 8? 6? da6? 1? r/w 10? 8? da8? 1? r/w 9? 7? da7? 1? r/w bit (cpu)? bit (data)? dadra? initial value? read/write 7? 5? da5? 1? r/w 6? 4? da4? 1? r/w 5? 3? da3? 1? r/w 4? 2? da2? 1? r/w 3? 1? da1? 1? r/w 0? ?? ?? 1? ? 2? 0? da0? 1? r/w 1? ?? cfs? 1? r/w dadrh dadrl da13? 1? r/w da12? 1? r/w da11? 1? r/w da10? 1? r/w da9? 1? r/w da6? 1? r/w da8? 1? r/w da7? 1? r/w dadrb? initial value? read/write da5? 1? r/w da4? 1? r/w da3? 1? r/w da2? 1? r/w da1? 1? r/w regs ? 1? r/w da0? 1? r/w cfs? 1? r/w there are two 16-bit readable/writable d/a data registers: dadra and dadrb. dadra corresponds to pwm d/a channel a, and dadrb to pwm d/a channel b. the cpu can read and write the pwm d/a data register values, but since dadra and dadrb are 16-bit registers, data transfers between them and the cpu are performed using a temporary register (temp). see section 10.3, bus master interface, for details. the least significant (cpu) bit of dadra is not used and is always read as 1. dadr is initialized to h'ffff by a reset, and in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode. bits 15 to 3pwm d/a data 13 to 0 (da13 to da0): the digital value to be converted to an analog value is set in the upper 14 bits of the pwm d/a data register. in each base cycle, the dacnt value is continually compared with these upper 14 bits to determine the duty cycle of the output waveform, and to decide whether to output a fine- adjustment pulse equal in width to the resolution. to enable this operation, the data register must be set within a range that depends on the carrier frequency select bit (cfs). if the dadr value is outside this range, the pwm output is held constant. a channel can be operated with 12-bit precision by keeping the two lowest data bits (da0 and da1) cleared to 0 and writing the data to be converted in the upper 12 bits. the two lowest data bits correspond to the two highest counter (dacnt) bits.
278 bit 1carrier frequency select (cfs) bit 1 cfs description 0 base cycle = resolution (t) 64 dadr range = h'0401 to h'fffd 1 base cycle = resolution (t) 256 dadr range = h'0103 to h'fffff (initial value) dadra bit 0reserved: this bit cannot be modified and is always read as 1. dadrb bit 0register select (regs): dadra and dacr, and dadrb and dacnt, are located at the same addresses. the regs bit specifies which registers can be accessed. the regs bit can be accessed regardless of whether dadrb or dacnt is selected. bit 0 regs description 0 dadra and dadrb can be accessed 1 dacr and dacnt can be accessed (initial value)
279 10.2.3 pwm d/a control register (dacr) 7? test? 0? r/w 6? pwme? 0? r/w 5? ?? 1? ? 4? ?? 1? ? 3? oeb? 0? r/w 0? cks? 0? r/w 2? oea? 0? r/w 1? os? 0? r/w bit? ? initial value? read/write dacr is an 8-bit readable/writable register that selects test mode, enables the pwm outputs, and selects the output phase and operating speed. dacr is initialized to h'30 by a reset, and in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7test mode (test): selects test mode, which is used in testing the chip. normally this bit should be cleared to 0. bit 7 test description 0 pwm (d/a) in user state: normal operation (initial value) 1 pwm (d/a) in test state: correct conversion results unobtainable bit 6pwm enable (pwme): starts or stops the pwm d/a counter (dacnt). bit 6 pwme description 0 dacnt operates as a 14-bit up-counter (initial value) 1 dacnt halts at h'0003 bits 5 and 4reserved: these bits cannot be modified and are always read as 1. bit 3output enable b (oeb): enables or disables output on pwm d/a channel b. bit 3 oeb description 0 pwm (d/a) channel b output (at the pwx1 pin) is disabled (initial value) 1 pwm (d/a) channel b output (at the pwx1 pin) is enabled
280 bit 2output enable a (oea): enables or disables output on pwm d/a channel a. bit 2 oea description 0 pwm (d/a) channel a output (at the pwx0 pin) is disabled (initial value) 1 pwm (d/a) channel a output (at the pwx0 pin) is enabled bit 1output select (os): selects the phase of the pwm d/a output. bit 1 os description 0 direct pwm output (initial value) 1 inverted pwm output bit 0clock select (cks): selects the pwm d/a resolution. if the system clock (?) frequency is 10 mhz, resolutions of 100 ns and 200 ns can be selected. bit 0 cks description 0 operates at resolution (t) = system clock cycle time (t cyc ) (initial value) 1 operates at resolution (t) = system clock cycle time (t cyc ) 2
281 10.2.4 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers, and is used to perform module stop mode control. when the mstp11 bit is set to 1, 14-bit pwm timer operation is halted and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 3module stop (mstp11): specifies pwmx module stop mode. mstpcrh bit 3 mstp11 description 0 pwmx module stop mode is cleared 1 pwmx module stop mode is set (initial value)
282 10.3 bus master interface dacnt, dadra, and dadrb are 16-bit registers. the data bus linking the bus master and the on-chip supporting modules, however, is only 8 bits wide. when the bus master accesses these registers, it therefore uses an 8-bit temporary register (temp). these registers are written and read as follows (taking the example of the cpu interface). write when the upper byte is written, the upper-byte write data is stored in temp. next, when the lower byte is written, the lower-byte write data and temp value are combined, and the combined 16-bit value is written in the register. read when the upper byte is read, the upper-byte value is transferred to the cpu and the lower- byte value is transferred to temp. next, when the lower byte is read, the lower-byte value in temp is transferred to the cpu. these registers should always be accessed 16 bits at a time using an mov instruction (by word access or two consecutive byte accesses), and the upper byte should always be accessed before the lower byte. correct data will not be transferred if only the upper byte or only the lower byte is accessed. also note that a bit manipulation instruction cannot be used to access these registers. figure 10.2 shows the data flow for access to dacnt. the other registers are accessed similarly. example 1: write to dacnt mov.w r0, @dacnt ; write r0 contents to dacnt example 2: read dadra mov.w @dadra, r0 ; copy contents of dadra to r0 table 10.3 read and write access methods for 16-bit registers read write register name word byte word byte dadra and dadrb yes yes yes dacnt yes yes notes: yes: permitted type of access. word access includes successive byte accesses to the upper byte (first) and lower byte (second). : this type of access may give incorrect results.
283 cpu (h'aa) upper byte bus interface module data bus upper-byte write temp (h'aa) dacntl ( ) dacnth ( ) cpu (h'57) lower byte bus interface module data bus lower-byte write temp (h'aa) dacntl (h'57) dacnth (h'aa) figure 10.2 (a) access to dacnt (cpu writes h'aa57 to dacnt)
284 cpu (h'aa) upper byte bus interface module data bus upper-byte read temp (h'57) dacntl (h'57) dacnth (h'aa) cpu (h'57) lower byte bus interface module data bus lower-byte read temp (h'57) dacntl ( ) dacnth ( ) figure 10.2 (b) access to dacnt (cpu reads h'aa57 from dacnt)
285 10.4 operation a pwm waveform like the one shown in figure 10.3 is output from the pwmx pin. when os = 0, the value in dadr corresponds to the total width (t l ) of the low (0) pulses output in one conversion cycle (256 pulses when cfs = 0, 64 pulses when cfs = 1). when os = 1, the output waveform is inverted and the dadr value corresponds to the total width (t h ) of the high (1) output pulses. figure 10.4 shows the types of waveform output available. t f t l t l = ? t ln (when os = 0) m n = 1 1 conversion cycle (t 2 14 (= 16384)) basic cycle (t 64 or t 256) t: resolution (when cfs = 0, m = 256; when cfs = 1, m = 64) figure 10.3 pwm d/a operation table 10.4 summarizes the relationships of the cks, cfs, and os bit settings to the resolution, base cycle, and conversion cycle. the pwm output remains flat unless dadr contains at least a certain minimum value. table 10.4 indicates the range of dadr settings that give an output waveform like the one in figure 10.3, and lists the conversion cycle length when low-order dadr bits are kept cleared to 0, reducing the conversion precision to 12 bits or 10 bits.
286 table 10.4 settings and operation (examples when ? = 10 mhz) fixed dadr bits bit data cks resolution t (s) cfs base cycle (s) conversion cycle (s) t l (if os = 0) t h (if os = 1) precision (bits) 3 2 1 0 conversion cycle * (s) 0 0.1 0 6.4 1638.4 1. always low (or high) (dadr = h'0001 to h'03fd) 14 1638.4 2. (data value) t (dadr = h'0401 to h'fffd) 12 0 0 409.6 10 0 0 0 0 102.4 1 25.6 1638.4 1. always low (or high) (dadr = h'0003 to h'00ff) 14 1638.4 2. (data value) t (dadr = h'0103 to h'ffff) 12 0 0 409.6 10 0 0 0 0 102.4 1 0.2 0 12.8 3276.8 1. always low (or high) (dadr = h'0001 to h'03fd) 14 3276.8 2. (data value) t (dadr = h'0401 to h'fffd) 12 0 0 819.2 10 0 0 0 0 204.8 1 51.2 3276.8 1. always low (or high) (dadr = h'0003 to h'00ff) 14 3276.8 2. (data value) t (dadr = h'0103 to h'ffff) 12 0 0 819.2 10 0 0 0 0 204.8 note: * this column indicates the conversion cycle when specific dadr bits are fixed.
287 1. os = 0 (dadr corresponds to t l ) a. cfs = 0 [base cycle = resolution (t) 64] t l1 t l2 t l3 t l255 t l256 t f1 t f2 t f255 t f256 1 conversion cycle t f1 = t f2 = t f3 = ???= t f255 = t f256 = t 64 t l1 + t l2 + t l3 + ???+ t l255 + t l256 = t l figure 10.4 (1) output waveform b. cfs = 1 [base cycle = resolution (t) 256] t l1 t l2 t l3 t l63 t l64 t f1 t f2 t f63 t f64 1 conversion cycle t f1 = t f2 = t f3 = ???= t f63 = t f64 = t 256 t l1 + t l2 + t l3 + ???+ t l63 + t l64 = t l figure 10.4 (2) output waveform
288 2. os = 1 (dadr corresponds to t h ) a. cfs = 0 [base cycle = resolution (t) 64] t h1 t h2 t h3 t h255 t h256 t f1 t f2 t f255 t f256 1 conversion cycle t f1 = t f2 = t f3 = ???= t f255 = t f256 = t 64 t h1 + t h2 + t h3 + ???+ t h255 + t h256 = t h figure 10.4 (3) output waveform b. cfs = 1 [base cycle = resolution (t) 256] t h1 t h2 t h3 t h63 t h64 t f1 t f2 t f63 t f64 1 conversion cycle t f1 = t f2 = t f3 = ???= t f63 = t f64 = t 256 t h1 + t h2 + t h3 + ???+ t h63 + t h64 = t h figure 10.4 (4) output waveform
289 section 11 16-bit free-running timer 11.1 overview the h8s/2148 series and h8s/2144 series have a single-channel on-chip 16-bit free-running timer (frt) module that uses a 16-bit free-running counter as a time base. applications of the frt module include rectangular-wave output (up to two independent waveforms), input pulse width measurement, and measurement of external clock periods. 11.1.1 features the features of the free-running timer module are listed below. selection of four clock sources ? the free-running counter can be driven by an internal clock source (?/2, ?/8, or ?/32), or an external clock input (enabling use as an external event counter). two independent comparators ? each comparator can generate an independent waveform. four input capture channels ? the current count can be captured on the rising or falling edge (selectable) of an input signal. ? the four input capture registers can be used separately, or in a buffer mode. counter can be cleared under program control ? the free-running counters can be cleared on compare-match a. seven independent interrupts ? two compare-match interrupts, four input capture interrupts, and one overflow interrupt can be requested independently. special functions provided by automatic addition function ? the contents of ocrar and ocraf can be added to the contents of ocra automatically, enabling a periodic waveform to be generated without software intervention. ? the contents of icrd can be added automatically to the contents of ocrdm 2, enabling input capture operations in this interval to be restricted.
290 11.1.2 block diagram figure 11.1 shows a block diagram of the free-running timer. external clock source internal clock sources clock select comparator a ocra (h/l) comparator b ocrb (h/l) bus interface internal data bus ?2 ?8 ?32 ftci compare- match a clear clock ftoa ftob overflow icra (h/l) compare- match b input capture frc (h/l) tcsr ftia ftib ftic ftid control logic module data bus tier tcr tocr interrupt signals icia icib icic icid ocia ocib fovi legend: ocra, b: frc: icra, b, c, d: tcsr: output compare register a, b (16 bits) free-running counter (16 bits) input capture register a, b, c, d (16 bits) timer control/status register (8 bits) tier: tcr: tocr: timer interrupt enable register (8 bits) timer control register (8 bits) timer output compare control register (8 bits) icrb (h/l) icrc (h/l) icrd (h/l) ocra r/f (h/l) + + ocrdm l 1 2 comparator m compare-match m figure 11.1 block diagram of 16-bit free-running timer
291 11.1.3 input and output pins table 11.1 lists the input and output pins of the free-running timer module. table 11.1 input and output pins of free-running timer module name abbreviation i/o function counter clock input ftci input frc counter clock input output compare a ftoa output output compare a output output compare b ftob output output compare b output input capture a ftia input input capture a input input capture b ftib input input capture b input input capture c ftic input input capture c input input capture d ftid input input capture d input
292 11.1.4 register configuration table 11.2 lists the registers of the free-running timer module. table 11.2 register configuration name abbreviation r/w initial value address * 1 timer interrupt enable register tier r/w h'01 h'ff90 timer control/status register tcsr r/(w) * 2 h'00 h'ff91 free-running counter frc r/w h'0000 h'ff92 output compare register a ocra r/w h'ffff h'ff94 * 3 output compare register b ocrb r/w h'ffff h'ff94 * 3 timer control register tcr r/w h'00 h'ff96 timer output compare control register tocr r/w h'00 h'ff97 input capture register a icra r h'0000 h'ff98 * 4 input capture register b icrb r h'0000 h'ff9a * 4 input capture register c icrc r h'0000 h'ff9c * 4 input capture register d icrd r h'0000 h'ff9e output compare register ar ocrar r/w h'ffff h'ff98 * 4 output compare register af ocraf r/w h'ffff h'ff9a * 4 output compare register dm ocrdm r/w h'0000 h'ff9c * 4 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. bits 7 to 1 are read-only; only 0 can be written to clear the flags. bit 0 is readable/writable. 3. ocra and ocrb share the same address. access is controlled by the ocrs bit in tocr. 4. icra, icrb, and icrc share the same addresses with ocrar, ocraf, and ocrdm. access is controlled by the icrs bit in tocr.
293 11.2 register descriptions 11.2.1 free-running counter (frc) bit initial 15 0 r/w 14 0 r/w 13 0 r/w 12 0 r/w 11 0 r/w 10 0 r/w 9 0 r/w 8 0 r/w 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 2 0 r/w 1 0 r/w 0 0 r/w value write read/ frc is a 16-bit readable/writable up-counter that increments on an internal pulse generated from a clock source. the clock source is selected by bits cks1 and cks0 in tcr. frc can also be cleared by compare-match a. when frc overflows from h'ffff to h'0000, the overflow flag (ovf) in tcsr is set to 1. frc is initialized to h'0000 by a reset and in hardware standby mode. 11.2.2 output compare registers a and b (ocra, ocrb) bit initial 15 1 r/w 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w value write read/ ocra and ocrb are 16-bit readable/writable registers, the contents of which are continually compared with the value in the frc. when a match is detected, the corresponding output compare flags (ocfa or ocfb) is set in tcsr. in addition, if the output enable bit (oea or oeb) in tocr is set to 1, when ocr and frc values match, the logic level selected by the output level bit (olvla or olvlb) in tocr is output at the output compare pin (ftoa or ftob). following a reset, the ftoa and ftob output levels are 0 until the first compare-match. ocr is initialized to h'ffff by a reset and in hardware standby mode.
294 11.2.3 input capture registers a to d (icra to icrd) bit initial 15 0 r 14 0 r 13 0 r 12 0 r 11 0 r 10 0 r 9 0 r 8 0 r 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 2 0 r 1 0 r 0 0 r value write read/ there are four input capture registers, a to d, each of which is a 16-bit read-only register. when the rising or falling edge of the signal at an input capture input pin (ftia to ftid) is detected, the current frc value is copied to the corresponding input capture register (icra to icrd). at the same time, the corresponding input capture flag (icfa to icfd) in tcsr is set to 1. the input capture edge is selected by the input edge select bits (iedga to iedgd) in tcr. icrc and icrd can be used as icra and icrb buffer registers, respectively, and made to perform buffer operations, by means of buffer enable bits a and b (bufea, bufeb) in tcr. figure 11.2 shows the connections when icrc is specified as the icra buffer register (bufea = 1). when icrc is used as the icra buffer, both rising and falling edges can be specified as transitions of the external input signal by setting iedga _ iedgc. when iedga = iedgc, either the rising or falling edge is designated. see table 11.3. note: the frc contents are transferred to the input capture register regardless of the value of the input capture flag (icf). bufea iedga iedgc ftia edge detect and capture signal generating circuit frc icrc icra figure 11.2 input capture buffering (example)
295 table 11.3 buffered input capture edge selection (example) iedga iedgc description 0 0 captured on falling edge of input capture a (ftia) (initial value) 1 captured on both rising and falling edges of input capture a (ftia) 10 1 captured on rising edge of input capture a (ftia) to ensure input capture, the width of the input capture pulse should be at least 1.5 system clock periods (1.5?). when triggering is enabled on both edges, the input capture pulse width should be at least 2.5 system clock periods. icr is initialized to h'0000 by a reset and in hardware standby mode. 11.2.4 output compare registers ar and af (ocrar, ocraf) bit initial 15 1 r/w 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w value write read/ ocrar and ocraf are 16-bit readable/writable registers. when the ocrams bit in tocr is set to 1, the operation of ocra is changed to include the use of ocrar and ocraf. the contents of ocrar and ocraf are automatically added alternately to ocra, and the result is written to ocra. the write operation is performed on the occurrence of compare-match a. in the first compare-match a after the ocrams bit is set to 1, ocraf is added. the operation due to compare-match a varies according to whether the compare-match follows addition of ocrar or ocraf. the value of the olvla bit in tocr is ignored, and 1 is output on a compare-match a following addition of ocraf, while 0 is output on a compare- match a following addition of ocrar. when the ocra automatically addition function is used, do not set internal clock ?/2 as the frc counter input clock together with an ocrar (or ocraf) value of h'0001 or less. ocrar and ocraf are initialized to h'ffff by a reset and in hardware standby mode.
296 11.2.5 output compare register dm (ocrdm) bit initial 15 0 r 14 0 r 13 0 r 12 0 r 11 0 r 10 0 r 9 0 r 8 0 r 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 2 0 r/w 1 0 r/w 0 0 r/w value write read/ ocrdm is a 16-bit readable/writable register in which the upper 8 bits are fixed at h'00. when the icrdms bit in tocr is set to 1 and the contents of ocrdm are other than h'0000, the operation of icrd is changed to include the use of ocrdm. the point at which input capture d occurs is taken as the start of a mask interval. next, twice the contents of ocrdm is added to the contents of icrd, and the result is compared with the frc value. the point at which the values match is taken as the end of the mask interval. new input capture d events are disabled during the mask interval. a mask interval is not generated when the icrdms bit is set to 1 and the contents of ocrdm are h'0000. ocrdm is initialized to h'0000 by a reset and in hardware standby mode.
297 11.2.6 timer interrupt enable register (tier) bit initial value read/write 7 iciae 0 r/w 6 icibe 0 r/w 5 icice 0 r/w 4 icide 0 3 ociae 0 r/w 0 ? 1 2 ocibe 0 r/w 1 ovie 0 r/w r/w tier is an 8-bit readable/writable register that enables and disables interrupts. tier is initialized to h'01 by a reset and in hardware standby mode. bit 7input capture interrupt a enable (iciae): selects whether to request input capture interrupt a (icia) when input capture flag a (icfa) in tcsr is set to 1. bit 7 iciae description 0 input capture interrupt request a (icia) is disabled (initial value) 1 input capture interrupt request a (icia) is enabled bit 6input capture interrupt b enable (icibe): selects whether to request input capture interrupt b (icib) when input capture flag b (icfb) in tcsr is set to 1. bit 6 icibe description 0 input capture interrupt request b (icib) is disabled (initial value) 1 input capture interrupt request b (icib) is enabled bit 5input capture interrupt c enable (icice): selects whether to request input capture interrupt c (icic) when input capture flag c (icfc) in tcsr is set to 1. bit 5 icice description 0 input capture interrupt request c (icic) is disabled (initial value) 1 input capture interrupt request c (icic) is enabled
298 bit 4input capture interrupt d enable (icide): selects whether to request input capture interrupt d (icid) when input capture flag d (icfd) in tcsr is set to 1. bit 4 icide description 0 input capture interrupt request d (icid) is disabled (initial value) 1 input capture interrupt request d (icid) is enabled bit 3output compare interrupt a enable (ociae): selects whether to request output compare interrupt a (ocia) when output compare flag a (ocfa) in tcsr is set to 1. bit 3 ociae description 0 output compare interrupt request a (ocia) is disabled (initial value) 1 output compare interrupt request a (ocia) is enabled bit 2output compare interrupt b enable (ocibe): selects whether to request output compare interrupt b (ocib) when output compare flag b (ocfb) in tcsr is set to 1. bit 2 ocibe description 0 output compare interrupt request b (ocib) is disabled (initial value) 1 output compare interrupt request b (ocib) is enabled bit 1timer overflow interrupt enable (ovie): selects whether to request a free-running timer overflow interrupt (fovi) when the timer overflow flag (ovf) in tcsr is set to 1. bit 1 ovie description 0 timer overflow interrupt request (fovi) is disabled (initial value) 1 timer overflow interrupt request (fovi) is enabled bit 0reserved: this bit cannot be modified and is always read as 1.
299 11.2.7 timer control/status register (tcsr) bit initial value read/write 7 icfa 0 r/(w) * 6 icfb 0 r/(w) * 5 icfc 0 4 icfd 0 3 ocfa 0 0 cclra 0 r/w 2 ocfb 0 r/(w) * 1 ovf 0 r/(w) * r/(w) * r/(w) * r/(w) * note: * only 0 can be written in bits 7 to 1 to clear these flags. tcsr is an 8-bit register used for counter clear selection and control of interrupt request signals. tcsr is initialized to h'00 by a reset and in hardware standby mode. timing is described in section 11.3, operation. bit 7input capture flag a (icfa): this status flag indicates that the frc value has been transferred to icra by means of an input capture signal. when bufea = 1, icfa indicates that the old icra value has been moved into icrc and the new frc value has been transferred to icra. icfa must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 7 icfa description 0 [clearing condition] read icfa when icfa = 1, then write 0 in icfa (initial value) 1 [setting condition] when an input capture signal causes the frc value to be transferred to icra
300 bit 6input capture flag b (icfb): this status flag indicates that the frc value has been transferred to icrb by means of an input capture signal. when bufeb = 1, icfb indicates that the old icrb value has been moved into icrd and the new frc value has been transferred to icrb. icfb must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 6 icfb description 0 [clearing condition] read icfb when icfb = 1, then write 0 in icfb (initial value) 1 [setting condition] when an input capture signal causes the frc value to be transferred to icrb bit 5input capture flag c (icfc): this status flag indicates that the frc value has been transferred to icrc by means of an input capture signal. when bufea = 1, on occurrence of the signal transition in ftic (input capture signal) specified by the iedgc bit, icfc is set but data is not transferred to icrc. therefore, in buffer operation, icfc can be used as an external interrupt signal (by setting the icice bit to 1). icfc must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 5 icfc description 0 [clearing condition] read icfc when icfc = 1, then write 0 in icfc (initial value) 1 [setting condition] when an input capture signal is received
301 bit 4input capture flag d (icfd): this status flag indicates that the frc value has been transferred to icrd by means of an input capture signal. when bufeb = 1, on occurrence of the signal transition in ftid (input capture signal) specified by the iedgd bit, icfd is set but data is not transferred to icrd. therefore, in buffer operation, icfd can be used as an external interrupt by setting the icide bit to 1. icfd must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 4 icfd description 0 [clearing condition] read icfd when icfd = 1, then write 0 in icfd (initial value) 1 [setting condition] when an input capture signal is received bit 3output compare flag a (ocfa): this status flag indicates that the frc value matches the ocra value. this flag must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 3 ocfa description 0 [clearing condition] read ocfa when ocfa = 1, then write 0 in ocfa (initial value) 1 [setting condition] when frc = ocra bit 2output compare flag b (ocfb): this status flag indicates that the frc value matches the ocrb value. this flag must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 2 ocfb description 0 [clearing condition] read ocfb when ocfb = 1, then write 0 in ocfb (initial value) 1 [setting condition] when frc = ocrb
302 bit 1timer overflow flag (ovf): this status flag indicates that the frc has overflowed (changed from h'ffff to h'0000). this flag must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 1 ovf description 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf (initial value) 1 [setting condition] when frc changes from h'ffff to h'0000 bit 0counter clear a (cclra): this bit selects whether the frc is to be cleared at compare-match a (when the frc and ocra values match). bit 0 cclra description 0 frc clearing is disabled (initial value) 1 frc is cleared at compare-match a
303 11.2.8 timer control register (tcr) 7 cmieb 0 r/w 6 cmiea 0 r/w 5 ovie 0 r/w 4 cclr1 0 r/w 3 cclr0 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write tcr is an 8-bit readable/writable register that selects the rising or falling edge of the input capture signals, enables the input capture buffer mode, and selects the frc clock source. tcr is initialized to h'00 by a reset and in hardware standby mode bit 7input edge select a (iedga): selects the rising or falling edge of the input capture a signal (ftia). bit 7 iedga description 0 capture on the falling edge of ftia (initial value) 1 capture on the rising edge of ftia bit 6input edge select b (iedgb): selects the rising or falling edge of the input capture b signal (ftib). bit 6 iedgb description 0 capture on the falling edge of ftib (initial value) 1 capture on the rising edge of ftib bit 5input edge select c (iedgc): selects the rising or falling edge of the input capture c signal (ftic). bit 5 iedgc description 0 capture on the falling edge of ftic (initial value) 1 capture on the rising edge of ftic
304 bit 4input edge select d (iedgd): selects the rising or falling edge of the input capture d signal (ftid). bit 4 iedgd description 0 capture on the falling edge of ftid (initial value) 1 capture on the rising edge of ftid bit 3buffer enable a (bufea): selects whether icrc is to be used as a buffer register for icra. bit 3 bufea description 0 icrc is not used as a buffer register for input capture a (initial value) 1 icrc is used as a buffer register for input capture a bit 2buffer enable b (bufeb): selects whether icrd is to be used as a buffer register for icrb. bit 2 bufeb description 0 icrd is not used as a buffer register for input capture b (initial value) 1 icrd is used as a buffer register for input capture b bits 1 and 0clock select (cks1, cks0): select external clock input or one of three internal clock sources for the frc. external clock pulses are counted on the rising edge of signals input to the external clock input pin (ftci). bit 1 bit 0 cks1 cks0 description 0 0 ?/2 internal clock source (initial value) 1 ?/8 internal clock source 1 0 ?/32 internal clock source 1 external clock source (rising edge)
305 11.2.9 timer output compare control register (tocr) bit? ? initial value? read/write 7? icrdms? 0? r/w 6? ocrams ? 0? r/w 5? icrs? 0? r/w 4? ocrs? 0 3? oea? 0 0? olvlb? 0? r/w 2? oeb? 0? r/w 1? olvla? 0? r/w r/w r/w tocr is an 8-bit readable/writable register that enables output from the output compare pins, selects the output levels, switches access between output compare registers a and b, controls the icrd and ocra operating mode, and switches access to input capture registers a, b, and c. tocr is initialized to h'00 by a reset and in hardware standby mode. bit 7input capture d mode select (icrdms): specifies whether icrd is used in the normal operating mode or in the operating mode using ocrdm. bit 7 icrdms description 0 the normal operating mode is specified for icrd (initial value) 1 the operating mode using ocrdm is specified for icrd bit 6output compare a mode select (ocrams): specifies whether ocra is used in the normal operating mode or in the operating mode using ocrar and ocraf. bit 6 ocrams description 0 the normal operating mode is specified for ocra (initial value) 1 the operating mode using ocrar and ocraf is specified for ocra bit 5input capture register select (icrs): the same addresses are shared by icra and ocrar, by icrb and ocraf, and by icrc and ocrdm. the icrs bit determines which registers are selected when the shared addresses are read or written to. the operation of icra, icrb, and icrc is not affected. bit 5 icrs description 0 the icra, icrb, and icrc registers are selected (initial value) 1 the ocrar, ocraf, and ocrdm registers are selected
306 bit 4output compare register select (ocrs): ocra and ocrb share the same address. when this address is accessed, the ocrs bit selects which register is accessed. this bit does not affect the operation of ocra or ocrb. bit 4 ocrs description 0 the ocra register is selected (initial value) 1 the ocrb register is selected bit 3output enable a (oea): enables or disables output of the output compare a signal (ftoa). bit 3 oea description 0 output compare a output is disabled (initial value) 1 output compare a output is enabled bit 2output enable b (oeb): enables or disables output of the output compare b signal (ftob). bit 2 oeb description 0 output compare b output is disabled (initial value) 1 output compare b output is enabled bit 1output level a (olvla): selects the logic level to be output at the ftoa pin in response to compare-match a (signal indicating a match between the frc and ocra values). when the ocrams bit is 1, this bit is ignored. bit 1 olvla description 0 0 output at compare-match a (initial value) 1 1 output at compare-match a
307 bit 0output level b (olvlb): selects the logic level to be output at the ftob pin in response to compare-match b (signal indicating a match between the frc and ocrb values). bit 0 olvlb description 0 0 output at compare-match b (initial value) 1 1 output at compare-match b 11.2.10 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp13 bit is set to 1, frt operation is stopped at the end of the bus cycle, and module stop mode is entered. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 5module stop (mstp13): specifies the frt module stop mode. bit 5 mstpcrh description 0 frt module stop mode is cleared 1 frt module stop mode is set (initial value)
308 11.3 operation 11.3.1 frc increment timing frc increments on a pulse generated once for each period of the selected (internal or external) clock source. internal clock: any of three internal clocks (?/2, ?/8, or ?/32) created by division of the system clock (?) can be selected by making the appropriate setting in bits cks1 and cks0 in tcr. figure 11.3 shows the increment timing. n ?1 frc input clock frc internal clock n n + 1 figure 11.3 increment timing with internal clock source
309 external clock: if external clock input is selected by bits cks1 and cks0 in tcr, frc increments on the rising edge of the external clock signal. the pulse width of the external clock signal must be at least 1.5 system clock (?) periods. the counter will not increment correctly if the pulse width is shorter than 1.5 system clock periods. figure 11.4 shows the increment timing. n + 1 n frc input clock frc external clock input pin figure 11.4 increment timing with external clock source
310 11.3.2 output compare output timing when a compare-match occurs, the logic level selected by the output level bit (olvla or olvlb) in tocr is output at the output compare pin (ftoa or ftob). figure 11.5 shows the timing of this operation for compare-match a. n + 1 n n + 1 n n ocra compare-match a signal frc olvla output compare a output pin ftoa clear * note: * vertical arrows ( ) indicate instructions executed by software. n figure 11.5 timing of output compare a output
311 11.3.3 frc clear timing frc can be cleared when compare-match a occurs. figure 11.6 shows the timing of this operation. n h'0000 frc compare-match a signal figure 11.6 clearing of frc by compare-match a 11.3.4 input capture input timing input capture input timing: an internal input capture signal is generated from the rising or falling edge of the signal at the input capture pin, as selected by the corresponding iedgx (x = a to d) bit in tcr. figure 11.7 shows the usual input capture timing when the rising edge is selected (iedgx = 1). input capture signal input capture input pin figure 11.7 input capture signal timing (usual case)
312 if the upper byte of icra/b/c/d is being read when the corresponding input capture signal arrives, the internal input capture signal is delayed by one system clock (?) period. figure 11.8 shows the timing for this case. input capture signal input capture input pin t 1 t 2 icra/b/c/d read cycle figure 11.8 input capture signal timing (input capture input when icra/b/c/d is read) buffered input capture input timing: icrc and icrd can operate as buffers for icra and icrb. figure 11.9 shows how input capture operates when icra and icrc are used in buffer mode and iedga and iedgc are set to different values (iedga = 0 and iedgc = 1, or iedg a = 1 and iedgc = 0), so that input capture is performed on both the rising and falling edges of ftia. n n + 1 n n + 1 m n n n mm mn ftia input capture signal frc icra icrc figure 11.9 buffered input capture timing (usual case)
313 when icrc or icrd is used as a buffer register, its input capture flag is set by the selected transition of its input capture signal. for example, if icrc is used to buffer icra, when the edge transition selected by the iedgc bit occurs on the ftic input capture line, icfc will be set, and if the iciec bit is set, an interrupt will be requested. the frc value will not be transferred to icrc, however. in buffered input capture, if the upper byte of either of the two registers to which data will be transferred (icra and icrc, or icrb and icrd) is being read when the input signal arrives, input capture is delayed by one system clock (?) period. figure 11.10 shows the timing when bufea = 1. input capture signal ftia t 1 t 2 read cycle: cpu reads icra or icrc figure 11.10 buffered input capture timing (input capture input when icra or icrc is read)
314 11.3.5 timing of input capture flag (icf) setting the input capture flag icfx (x = a, b, c, d) is set to 1 by the internal input capture signal. the frc value is simultaneously transferred to the corresponding input capture register (icrx). figure 11.11 shows the timing of this operation. icfa/b/c/d frc input capture signal n n icra/b/c/d figure 11.11 setting of input capture flag (icfa/b/c/d)
315 11.3.6 setting of output compare flags a and b (ocfa, ocfb) the output compare flags are set to 1 by an internal compare-match signal generated when the frc value matches the ocra or ocrb value. this compare-match signal is generated at the last state in which the two values match, just before frc increments to a new value. accordingly, when the frc and ocr values match, the compare-match signal is not generated until the next period of the clock source. figure 11.12 shows the timing of the setting of ocfa and ocfb. ocra or ocrb compare-match signal frc n n + 1 n ocfa or ocfb figure 11.12 setting of output compare flag (ocfa, ocfb)
316 11.3.7 setting of frc overflow flag (ovf) the frc overflow flag (ovf) is set to 1 when frc overflows (changes from h'ffff to h'0000). figure 11.13 shows the timing of this operation. h'ffff h'0000 overflow signal frc ovf figure 11.13 setting of overflow flag (ovf)
317 11.3.8 automatic addition of ocra and ocrar/ocraf when the ocrams bit in tocr is set to 1, the contents of ocrar and ocraf are automatically added to ocra alternately, and when an ocra compare-match occurs a write to ocra is performed. the ocra write timing is shown in figure 11.14. ocrar, f ocra frc a n n+a compare-match signal n n+1 figure 11.14 ocra automatic addition timing
318 11.3.9 icrd and ocrdm mask signal generation when the icrdms bit in tocr is set to 1 and the contents of ocrdm are other than h'0000, a signal that masks the icrd input capture function is generated. the mask signal is set by the input capture signal. the mask signal setting timing is shown in figure 11.15. the mask signal is cleared by the sum of the icrd contents and twice the ocrdm contents, and an frc compare-match. the mask signal clearing timing is shown in figure 11.16. input capture mask signal input capture signal figure 11.15 input capture mask signal setting timing compare-match signal icrd + ocrdm 2 frc n input capture mask signal n n+1 figure 11.16 input capture mask signal clearing timing
319 11.4 interrupts the free-running timer can request seven interrupts (three types): input capture a to d (icia, icib, icic, icid), output compare a and b (ocia and ocib), and overflow (fovi). each interrupt can be enabled or disabled by an enable bit in tier. independent signals are sent to the interrupt controller for each interrupt. table 11.4 lists information about these interrupts. table 11.4 free-running timer interrupts interrupt description dtc activation priority icia requested by icfa possible high icib requested by icfb possible icic requested by icfc not possible icid requested by icfd not possible ocia requested by ocfa possible ocib requested by ocfb possible fovi requested by ovf not possible low
320 11.5 sample application in the example below, the free-running timer is used to generate pulse outputs with a 50% duty cycle and arbitrary phase relationship. the programming is as follows: the cclra bit in tcsr is set to 1. each time a compare-match interrupt occurs, software inverts the corresponding output level bit in tocr (olvla or olvlb). frc counter clear h'ffff ocra ocrb h'0000 ftoa ftob figure 11.17 pulse output (example)
321 11.6 usage notes application programmers should note that the following types of contention can occur in the free-running timer. contention between frc write and clear: if an internal counter clear signal is generated during the state after an frc write cycle, the clear signal takes priority and the write is not performed. figure 11.18 shows this type of contention. t 1 t 2 frc write cycle address frc address internal write signal ? counter clear signal frc n h'0000 figure 11.18 frc write-clear contention
322 contention between frc write and increment: if an frc increment pulse is generated during the state after an frc write cycle, the write takes priority and frc is not incremented. figure 11.19 shows this type of contention. t 1 t 2 frc write cycle address internal write signal ? frc input clock frc n m write data frc address figure 11.19 frc write-increment contention
323 contention between ocr write and compare-match: if a compare-match occurs during the state after an ocra or ocrb write cycle, the write takes priority and the compare-match signal is inhibited. figure 11.20 shows this type of contention. if automatic addition of ocrar/ocraf to ocra is selected, and a compare-match occurs in the cycle following the ocra, ocrar and ocraf write cycle, the ocra, ocrar and ocraf write takes priority and the compare-match signal is inhibited. consequently, the result of the automatic addition is not written to ocra. t 1 t 2 ocra or ocrb write cycle address internal write signal ? frc ocr n m write data ocr address n n + 1 compare-match signal inhibited figure 11.20 contention between ocr write and compare-match (when automatic addition function is not used)
324 switching of internal clock and frc operation: when the internal clock is changed, the changeover may cause frc to increment. this depends on the time at which the clock select bits (cks1 and cks0) are rewritten, as shown in table 11.5. when an internal clock is used, the frc clock is generated on detection of the falling edge of the internal clock scaled from the system clock (?). if the clock is changed when the old source is high and the new source is low, as in case no. 3 in table 11.5, the changeover is regarded as a falling edge that triggers the frc increment clock pulse. switching between an internal and external clock can also cause frc to increment. table 11.5 switching of internal clock and frc operation no. timing of switchover by means of cks1 and cks0 bits frc operation 1 switching from low to low n + 1 clock before switchover clock after switchover frc clock frc cks bit rewrite n 2 switching from low to high n + 1 n + 2 clock before switchover clock after switchover frc clock frc cks bit rewrite n
325 table 11.5 switching of internal clock and frc operation (cont) no. timing of switchover by means of cks1 and cks0 bits frc operation 3 switching from high to low n + 1 n n + 2 * clock before switchover clock after switchover frc clock frc cks bit rewrite 4 switching from high to high n + 1 n + 2 n clock before switchover clock after switchover frc clock cks bit rewrite frc note: * generated on the assumption that the switchover is a falling edge; frc is incremented.
326
327 section 12 8-bit timers 12.1 overview the h8s/2148 series and h8s/2144 series include an 8-bit timer module with two channels (tmr0 and tmr1). each channel has an 8-bit counter (tcnt) and two time constant registers (tcora and tcorb) that are constantly compared with the tcnt value to detect compare- matches. the 8-bit timer module can be used as a multifunction timer in a variety of applications, such as generation of a rectangular-wave output with an arbitrary duty cycle. the h8s/2148 series also has two similar 8-bit timer channels (tmrx and tmry), and the h8s/2144 series has one (tmry). these channels can be used in a connected configuration using the timer connection function. tmrx and tmry have greater input/output and interrupt function related restrictions than tmr0 and tmr1. 12.1.1 features selection of clock sources ? tmr0, tmr1: the counter input clock can be selected from six internal clocks and an external clock (enabling use as an external event counter). ? tmrx, tmry: the counter input clock can be selected from three internal clocks and an external clock (enabling use as an external event counter). selection of three ways to clear the counters ? the counters can be cleared on compare-match a or b, or by an external reset signal. timer output controlled by two compare-match signals ? the timer output signal in each channel is controlled by two independent compare-match signals, enabling the timer to be used for various applications, such as the generation of pulse output or pwm output with an arbitrary duty cycle. (note: tmry does not have a timer output pin.) cascading of the two channels (tmr0, tmr1) ? operation as a 16-bit timer can be performed using channel 0 as the upper half and channel 1 as the lower half (16-bit count mode). ? channel 1 can be used to count channel 0 compare-match occurrences (compare-match count mode). multiple interrupt sources for each channel ? tmr0, tmr1, tmry: two compare-match interrupts and one overflow interrupt can be requested independently. ? tmrx: one input capture source is available.
328 12.1.2 block diagram figure 12.1 shows a block diagram of the 8-bit timer module (tmr0 and tmr1). tmrx and tmry have a similar configuration, but cannot be cascaded. tmrx also has an input capture function. for details, see section 13, timer connection. external clock sources internal clock sources tmr0 ?8, ?2 ?64, ?32 ?1024, ?256 clock 1 clock 0 compare-match a1 compare-match a0 clear 1 cmia0 cmib0 ovi0 cmia1 cmib1 ovi1 interrupt signals tmo0 tmri0 internal bus tcora0 comparator a0 comparator b0 tcorb0 tcsr0 tcr0 tcora1 comparator a1 tcnt1 comparator b1 tcorb1 tcsr1 tcr1 tmci0 tmci1 tcnt0 overflow 1 overflow 0 compare-match b1 compare-match b0 tmo1 tmri1 clock select control logic clear 0 tmr1 ?8, ?2 ?64, ?128 ?1024, ?2048 tmrx ? ?2 ?4 tmry ?4 ?256 ?2048 figure 12.1 block diagram of 8-bit timer module
329 12.1.3 pin configuration table 12.1 summarizes the input and output pins of the 8-bit timer module. table 12.1 8-bit timer input and output pins channel name symbol * i/o function 0 timer output tmo0 output output controlled by compare-match timer clock input tmci0 input external clock input for the counter timer reset input tmri0 input external reset input for the counter 1 timer output tmo1 output output controlled by compare-match timer clock input tmci1 input external clock input for the counter timer reset input tmri1 input external reset input for the counter x timer output tmox output output controlled by compare-match timer clock/ reset input hfbacki/tmix (tmcix/tmrix) input external clock/reset input for the counter y timer clock/reset input vsynci/tmiy (tmciy/tmriy) input external clock/reset input for the counter note: * the abbreviations tmo, tmci, and tmri are used in the text, omitting the channel number. channel x and y i/o pins have the same internal configuration as channels 0 and 1, and therefore the same abbreviations are used.
330 12.1.4 register configuration table 12.2 summarizes the registers of the 8-bit timer module. table 12.2 8-bit timer registers channel name abbreviation * 3 r/w initial value address * 1 0 timer control register 0 tcr0 r/w h'00 h'ffc8 timer control/status register 0 tcsr0 r/(w) * 2 h'00 h'ffca time constant register a0 tcora0 r/w h'ff h'ffcc time constant register b0 tcorb0 r/w h'ff h'ffce time counter 0 tcnt0 r/w h'00 h'ffd0 1 timer control register 1 tcr1 r/w h'00 h'ffc9 timer control/status register 1 tcsr1 r/(w) * 2 h'10 h'ffcb time constant register a1 tcora1 r/w h'ff h'ffcd time constant register b1 tcorb1 r/w h'ff h'ffcf timer counter 1 tcnt1 r/w h'00 h'ffd1 common serial/timer control register stcr r/w h'00 h'ffc3 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 timer connection register s tconrs r/w h'00 h'fffe x timer control register x tcrx r/w h'00 h'fff0 timer control/status register x tcsrx r/(w) * 2 h'00 h'fff1 time constant register ax tcorax r/w h'ff h'fff6 time constant register bx tcorbx r/w h'ff h'fff7 timer counter x tcntx r/w h'00 h'fff4 time constant register c tcorc r/w h'ff h'fff5 input capture register r ticrr r h'00 h'fff2 input capture register f ticrf r h'00 h'fff3 y timer control register y tcry r/w h'00 h'fff0 timer control/status register y tcsry r/(w) * 2 h'00 h'fff1 time constant register ay tcoray r/w h'ff h'fff2 time constant register by tcorby r/w h'ff h'fff3 timer counter y tcnty r/w h'00 h'fff4 timer input select register tisr r/w h'fe h'fff5 notes: 1. lower 16 bits of the address. 2. only 0 can be written in bits 7 to 5, to clear these flags. 3. the abbreviations tcr, tcsr, tcora, tcorb, and tcnt are used in the text, omitting the channel designation (0, 1, x, or y).
331 each pair of registers for channel 0 and channel 1 comprises a 16-bit register with the upper 8 bits for channel 0 and the lower 8 bits for channel 1, so they can be accessed together by word access. (access is not divided into two 8-bit accesses.) in the h8s/2148 series, certain of the channel x and channel y registers are assigned to the same address. the tmrx/y bit in tconrs determines which register is accessed. 12.2 register descriptions 12.2.1 timer counter (tcnt) 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w tcntx,tcnty bit initial value read/write 15 0 r/w bit initial value read/write 14 0 r/w 13 0 r/w 12 0 r/w 11 0 r/w 10 0 r/w 9 0 r/w 8 0 r/w 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 2 0 r/w 1 0 r/w 0 0 r/w tcnt0 tcnt1 each tcnt is an 8-bit readable/writable up-counter. tcnt0 and tcnt1 comprise a single 16-bit register, so they can be accessed together by word access. tcnt increments on pulses generated from an internal or external clock source. this clock source is selected by clock select bits cks2 to cks0 in tcr. tcnt can be cleared by an external reset input signal or compare-match signal. counter clear bits cclr1 and cclr0 in tcr select the method of clearing. when tcnt overflows from h'ff to h'00, the overflow flag (ovf) in tcsr is set to 1. the timer counters are initialized to h'00 by a reset and in hardware standby mode.
332 12.2.2 time constant register a (tcora) 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w tcorax, tcoray bit initial value read/write 15 1 r/w bit initial value read/write 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w tcora0 tcora1 tcora is an 8-bit readable/writable register. tcora0 and tcora1 comprise a single 16-bit register, so they can be accessed together by word access. tcora is continually compared with the value in tcnt. when a match is detected, the corresponding compare-match flag a (cmfa) in tcsr is set. note, however, that comparison is disabled during the t2 state of a tcora write cycle. the timer output can be freely controlled by these compare-match signals and the settings of output select bits os1 and os0 in tcsr. tcora is initialized to h'ff by a reset and in hardware standby mode.
333 12.2.3 time constant register b (tcorb) 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w tcorbx, tcorby bit initial value read/write 15 1 r/w bit initial value read/write 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w tcorb0 tcorb1 tcorb is an 8-bit readable/writable register. tcorb0 and tcorb1 comprise a single 16-bit register, so they can be accessed together by word access. tcorb is continually compared with the value in tcnt. when a match is detected, the corresponding compare-match flag b (cmfb) in tcsr is set. note, however, that comparison is disabled during the t2 state of a tcorb write cycle. the timer output can be freely controlled by these compare-match signals and the settings of output select bits os3 and os2 in tcsr. tcorb is initialized to h'ff by a reset and in hardware standby mode.
334 12.2.4 timer control register (tcr) 7 cmieb 0 r/w 6 cmiea 0 r/w 5 ovie 0 r/w 4 cclr1 0 r/w 3 cclr0 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write tcr is an 8-bit readable/writable register that selects the clock source and the time at which tcnt is cleared, and enables interrupts. tcr is initialized to h'00 by a reset and in hardware standby mode. for details of the timing, see section 12.3, operation. bit 7compare-match interrupt enable b (cmieb): selects whether the cmfb interrupt request (cmib) is enabled or disabled when the cmfb flag in tcsr is set to 1. note that a cmib interrupt is not requested by tmrx, regardless of the cmieb value. bit 7 cmieb description 0 cmfb interrupt request (cmib) is disabled (initial value) 1 cmfb interrupt request (cmib) is enabled bit 6compare-match interrupt enable a (cmiea): selects whether the cmfa interrupt request (cmia) is enabled or disabled when the cmfa flag in tcsr is set to 1. note that a cmia interrupt is not requested by tmrx, regardless of the cmiea value. bit 6 cmiea description 0 cmfa interrupt request (cmia) is disabled (initial value) 1 cmfa interrupt request (cmia) is enabled
335 bit 5timer overflow interrupt enable (ovie): selects whether the ovf interrupt request (ovi) is enabled or disabled when the ovf flag in tcsr is set to 1. note that an ovi interrupt is not requested by tmrx, regardless of the ovie value. bit 5 ovie description 0 ovf interrupt request (ovi) is disabled (initial value) 1 ovf interrupt request (ovi) is enabled bits 4 and 3counter clear 1 and 0 (cclr1, cclr0): these bits select the method by which the timer counter is cleared: by compare-match a or b, or by an external reset input. bit 4 bit 3 cclr1 cclr0 description 0 0 clearing is disabled (initial value) 1 cleared on compare-match a 1 0 cleared on compare-match b 1 cleared on rising edge of external reset input
336 bits 2 to 0clock select 2 to 0 (cks2 to cks0): these bits select whether the clock input to tcnt is an internal or external clock. the input clock can be selected from either six or three clocks, all divided from the system clock (?). the falling edge of the selected internal clock triggers the count. when use of an external clock is selected, three types of count can be selected: at the rising edge, the falling edge, and both rising and falling edges. some functions differ between channel 0 and channel 1, because of the cascading function. tcr stcr bit 2 bit 1 bit 0 bit 1 bit 0 channel cks2 cks1 cks0 icks1 icks0 description 0 0 0 0 clock input disabled (initial value) 0 0 1 0 ?/8 internal clock source, counted on the falling edge 0 0 1 1 ?/2 internal clock source, counted on the falling edge 0 1 0 0 ?/64 internal clock source, counted on the falling edge 0 1 0 1 ?/32 internal clock source, counted on the falling edge 0 1 1 0 ?/1024 internal clock source, counted on the falling edge 0 1 1 1 ?/256 internal clock source, counted on the falling edge 1 0 0 counted on tcnt1 overflow signal * 1 0 0 0 clock input disabled (initial value) 0 0 1 0 ?/8 internal clock source, counted on the falling edge 0 0 1 1 ?/2 internal clock source, counted on the falling edge 0 1 0 0 ?/64 internal clock source, counted on the falling edge 0 1 0 1 ?/128 internal clock source, counted on the falling edge 0 1 1 0 ?/1024 internal clock source, counted on the falling edge 0 1 1 1 ?/2048 internal clock source, counted on the falling edge 1 0 0 counted on tcnt0 compare-match a *
337 tcr stcr bit 2 bit 1 bit 0 bit 1 bit 0 channel cks2 cks1 cks0 icks1 icks0 description x 0 0 0 clock input disabled (initial value) 0 0 1 counted on ? internal clock source 0 1 0 ?/2 internal clock source, counted on the falling edge 0 1 1 ?/4 internal clock source, counted on the falling edge 1 0 0 clock input disabled y 0 0 0 clock input disabled (initial value) 0 0 1 ?/4 internal clock source, counted on the falling edge 0 1 0 ?/256 internal clock source, counted on the falling edge 0 1 1 ?/2048 internal clock source, counted on the falling edge 1 0 0 clock input disabled common 1 0 1 external clock source, counted at rising edge 1 1 0 external clock source, counted at falling edge 1 1 1 external clock source, counted at both rising and falling edges note: * if the count input of channel 0 is the tcnt1 overflow signal and that of channel 1 is the tcnt0 compare-match signal, no incrementing clock will be generated. do not use this setting.
338 12.2.5 timer control/status register (tcsr) 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 icie 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write note: * only 0 can be written in bits 7 to 5, and in bit 4 in tcsrx, to clear these flags. tcsry 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 icf 0 r/(w) * 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsrx 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 ? 1 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsr1 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 adte 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsr0 tcsr is an 8-bit register that indicates compare-match and overflow statuses (and input capture status in tmrx only), and controls compare-match output. tcsr0, tcsrx, and tcsry are initialized to h'00, and tcsr1 is initialized to h'10, by a reset and in hardware standby mode.
339 bit 7compare-match flag b (cmfb): status flag indicating whether the values of tcnt and tcorb match. bit 7 cmfb description 0 [clearing conditions] read cmfb when cmfb = 1, then write 0 in cmfb when the dtc is activated by a cmib interrupt (initial value) 1 [setting condition] when tcnt = tcorb bit 6compare-match flag a (cmfa): status flag indicating whether the values of tcnt and tcora match. bit 6 cmfa description 0 [clearing conditions] read cmfa when cmfa = 1, then write 0 in cmfa when the dtc is activated by a cmia interrupt (initial value) 1 [setting condition] when tcnt = tcora bit 5 timer overflow flag (ovf): status flag indicating that tcnt has overflowed (changed from h'ff to h'00). bit 5 ovf description 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf (initial value) 1 [setting condition] when tcnt overflows from h'ff to h'00
340 tcsr0 bit 4a/d trigger enable (adte): enables or disables a/d converter start requests by compare-match a. bit 4 adte description 0 a/d converter start requests by compare-match a are disabled (initial value) 1 a/d converter start requests by compare-match a are enabled tcsr1 bit 4reserved: this bit cannot be modified and is always read as 1. tcsrx bit 4input capture flag (icf): status flag that indicates detection of a rising edge followed by a falling edge in the external reset signal after the icst bit in tconri has been set to 1. bit 4 icf description 0 [clearing condition] read icf when icf = 1, then write 0 in icf (initial value) 1 [setting condition] when a rising edge followed by a falling edge is detected in the external reset signal after the icst bit in tconri has been set to 1 tcsry bit 4input capture interrupt enable (icie): selects enabling or disabling of the interrupt request by icf (icix) when the icf bit in tcsrx is set to 1. bit 4 icie description 0 interrupt request by icf (icix) is disabled (initial value) 1 interrupt request by icf (icix) is enabled
341 bits 3 to 0output select 3 to 0 (os3 to os0): these bits specify how the timer output level is to be changed by a compare-match of tcor and tcnt. os3 and os2 select the effect of compare-match b on the output level, os1 and os0 select the effect of compare-match a on the output level, and both of them can be controlled independently. note, however, that priorities are set such that: trigger output > 1 output > 0 output. if compare- matches occur simultaneously, the output changes according to the compare-match with the higher priority. timer output is disabled when bits os3 to os0 are all 0. after a reset, the timer output is 0 until the first compare-match occurs. bit 3 bit 2 os3 os2 description 0 0 no change when compare-match b occurs (initial value) 1 0 is output when compare-match b occurs 1 0 1 is output when compare-match b occurs 1 output is inverted when compare-match b occurs (toggle output) bit 1 bit 0 os1 os0 description 0 0 no change when compare-match a occurs (initial value) 1 0 is output when compare-match a occurs 1 0 1 is output when compare-match a occurs 1 output is inverted when compare-match a occurs (toggle output)
342 12.2.6 serial/timer control register (stcr) 7 iics 0 r/w 6 iicx1 0 r/w 5 iicx0 0 r/w 4 iice 0 r/w 3 flshe 0 r/w 0 icks0 0 r/w 2 ? 0 r/w 1 icks1 0 r/w bit initial value read/write stcr is an 8-bit readable/writable register that controls register access, the iic operating mode (when the on-chip iic option is included), and on-chip flash memory (in f-ztat versions), and also selects the tcnt input clock. for details on functions not related to the 8-bit timers, see section 3.2.4, serial/timer control register (stcr), and the descriptions of the relevant modules. if a module controlled by stcr is not used, do not write 1 to the corresponding bit. stcr is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 4i 2 c control (iics, iicx1, iicx0, iice): these bits control the operation of the i 2 c bus interface when the iic option is included on-chip. see section 16, i 2 c bus interface, for details. bit 3flash memory control register enable (flshe): controls the operation of the flash memory in f-ztat versions. see section 22, rom, for details. bit 2reserved: do not write 1 to this bit. bits 1 and 0internal clock select 1 and 0 (icks1, icks0): these bits, together with bits cks2 to cks0 in tcr, select the clock to be input to tcnt. for details, see section 12.2.4, timer control register.
343 12.2.7 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write only bit 1 is described here. for details on functions not related to the 8-bit timers, see sections 3.2.2 and 5.2.1, system control register (syscr), and the descriptions of the relevant modules. bit 1host interface enable (hie): controls cpu access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers. bit 1 hie description 0 cpu access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers, is enabled (initial value) 1 cpu access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers, is disabled
344 12.2.8 timer connection register s (tconrs) 7 tmrx/y 0 r/w 6 isgene 0 r/w 5 homod1 0 r/w 4 homod0 0 r/w 3 vomod1 0 r/w 0 clmod0 0 r/w 2 vomod0 0 r/w 1 clmod1 0 r/w bit initial value read/write tconrs is an 8-bit readable/writable register that controls access to the tmrx and tmry registers and timer connection operation. tconrs is initialized to h'00 by a reset and in hardware standby mode. bit 7tmrx/tmry access select (tmrx/y): the tmrx and tmry registers can only be accessed when the hie bit in syscr is cleared to 0. in the h8s/2148 series, some of the tmrx registers and the tmry registers are assigned to the same memory space addresses (h'fff0 to h'fff5), and the tmrx/y bit determines which registers are accessed. in the h8s/2144 series, there is no control of tmry register access by this bit. bit 7 accessible registers tmrx/y h'fff0 h'fff1 h'fff2 h'fff3 h'fff4 h'fff5 h'fff6 h'fff7 0 (initial value) tmrx tcrx tmrx tcsrx tmrx ticrr tmrx ticrf tmrx tcntx tmrx tcorc tmrx tcorax tmrx tcorbx 1 tmry tcry tmry tcsry tmry tcoray tmry tcorby tmry tcnty tmry tisr
345 12.2.9 input capture register (ticr) [tmrx additional function] 7 0 6 0 5 0 4 0 3 0 0 0 2 0 1 0 bit initial value read/write ticr is an 8-bit internal register to which the contents of tcnt are transferred on the falling edge of external reset input. the cpu cannot read or write to ticr directly. the ticr function is used in timer connection. for details, see section 13, timer connection. 12.2.10 time constant register c (tcorc) [tmrx additional function] 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write tcorc is an 8-bit readable/writable register. the sum of the contents of tcorc and ticr is continually compared with the value in tcnt. when a match is detected, a compare-match c signal is generated. note, however, that comparison is disabled during the t2 state of a tcorc write cycle and a ticr input capture cycle. tcorc is initialized to h'ff by a reset and in hardware standby mode. the tcorc function is used in timer connection. for details, see section 13, timer connection. 12.2.11 input capture registers r and f (ticrr, ticrf) [tmrx additional functions] 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r bit initial value read/write ticrr and ticrf are 8-bit read-only registers. when the icst bit in tconri is set to 1, ticrr and ticrf capture the contents of tcnt successively on the rise and fall of the external reset input. when one capture operation ends, the icst bit is cleared to 0. ticrr and ticrf are each initialized to h'00 by a reset and in hardware standby mode.
346 the ticrr and ticrf functions are used in timer connection. for details, see section 13, timer connection. 12.2.12 timer input select register (tisr) [tmry additional function] 7 ? 1 6 ? 1 5 ? 1 4 ? 1 3 ? 1 0 is 0 r/w 2 ? 1 1 ? 1 bit initial value read/write tisr is an 8-bit readable/writable register that selects the external clock/reset signal source for the counter. tisr is initialized to h'fe by a reset and in hardware standby mode. bits 7 to 1reserved: do not write 0 to these bits. bit 0input select (is): selects the internal synchronization signal (ivg signal) or the timer clock/reset input pin (vsynci/tmiy (tmciy/tmriy)) as the external clock/reset signal source for the counter. bit 0 is description 0 ivg signal is selected (h8s/2148 series) external clock/reset input is disabled (h8s/2144 series) (initial value) 1 vsynci/tmiy (tmciy/tmriy) is selected
347 12.2.13 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers, and is used to perform module stop mode control. when the mstp12 bit or mstp8 bit is set to 1, 8-bit timer operation is halted on channels 0 and 1 or channels x and y, respectively, and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 4module stop (mstp12): specifies 8-bit timer (channel 0/1) module stop mode. mstpcrh bit 4 mstp12 description 0 8-bit timer (channel 0/1) module stop mode is cleared 1 8-bit timer (channel 0/1) module stop mode is set (initial value) mstpcrh bit 0module stop (mstp8): specifies 8-bit timer (channel x/y) and timer connection module stop mode. mstpcrh bit 0 mstp8 description 0 8-bit timer (channel x/y) and timer connection module stop mode is cleared 1 8-bit timer (channel x/y) and timer connection module stop mode is set (initial value)
348 12.3 operation 12.3.1 tcnt incrementation timing tcnt is incremented by input clock pulses (either internal or external). internal clock: an internal clock created by dividing the system clock (?) can be selected by setting bits cks2 to cks0 in tcr. figure 12.2 shows the count timing. internal clock tcnt input clock tcnt n ?1 n n + 1 figure 12.2 count timing for internal clock input
349 external clock: three incrementation methods can be selected by setting bits cks2 to cks0 in tcr: at the rising edge, the falling edge, and both rising and falling edges. note that the external clock pulse width must be at least 1.5 states for incrementation at a single edge, and at least 2.5 states for incrementation at both edges. the counter will not increment correctly if the pulse width is less than these values. figure 12.3 shows the timing of incrementation at both edges of an external clock signal. external clock input pin tcnt input clock tcnt n ?1 n n + 1 figure 12.3 count timing for external clock input
350 12.3.2 compare-match timing setting of compare-match flags a and b (cmfa, cmfb): the cmfa and cmfb flags in tcsr are set to 1 by a compare-match signal generated when the tcor and tcnt values match. the compare-match signal is generated at the last state in which the match is true, just before the timer counter is updated. therefore, when tcor and tcnt match, the compare-match signal is not generated until the next incrementation clock input. figure 12.4 shows this timing. tcnt n n + 1 tcor n compare-match signal cmf figure 12.4 timing of cmf setting timer output timing: when compare-match a or b occurs, the timer output changes as specified by the output select bits (os3 to os0) in tcsr. depending on these bits, the output can remain the same, be set to 0, be set to 1, or toggle. figure 12.5 shows the timing when the output is set to toggle at compare-match a. compare-match a signal timer output pin figure 12.5 timing of timer output
351 timing of compare-match clear: tcnt is cleared when compare-match a or b occurs, depending on the setting of the cclr1 and cclr0 bits in tcr. figure 12.6 shows the timing of this operation. n h'00 compare-match signal tcnt figure 12.6 timing of compare-match clear 12.3.3 tcnt external reset timing tcnt is cleared at the rising edge of an external reset input, depending on the settings of the cclr1 and cclr0 bits in tcr. the width of the clearing pulse must be at least 1.5 states. figure 12.7 shows the timing of this operation. clear signal external reset input pin tcnt n h'00 n ?1 figure 12.7 timing of clearing by external reset input
352 12.3.4 timing of overflow flag (ovf) setting ovf in tcsr is set to 1 when the timer count overflows (changes from h'ff to h'00). figure 12.8 shows the timing of this operation. ovf overflow signal tcnt h'ff h'00 figure 12.8 timing of ovf setting
353 12.3.5 operation with cascaded connection if bits cks2 to cks0 in either tcr0 or tcr1 are set to b'100, the 8-bit timers of the two channels are cascaded. with this configuration, a single 16-bit timer can be used (16-bit timer mode) or compare-matches of 8-bit channel 0 can be counted by the timer of channel 1 (compare-match count mode). in this case, the timer operates as described below. 16-bit count mode: when bits cks2 to cks0 in tcr0 are set to b'100, the timer functions as a single 16-bit timer with channel 0 occupying the upper 8 bits and channel 1 occupying the lower 8 bits. setting of compare-match flags ? the cmf flag in tcsr0 is set to 1 when a 16-bit compare-match occurs. ? the cmf flag in tcsr1 is set to 1 when a lower 8-bit compare-match occurs. counter clear specification ? if the cclr1 and cclr0 bits in tcr0 have been set for counter clear at compare- match, the 16-bit counter (tcnt0 and tcnt1 together) is cleared when a 16-bit compare-match occurs. the 16-bit counter (tcnt0 and tcnt1 together) is cleared even if counter clear by the tmri0 pin has also been set. ? the settings of the cclr1 and cclr0 bits in tcr1 are ignored. the lower 8 bits cannot be cleared independently. pin output ? control of output from the tmo0 pin by bits os3 to os0 in tcsr0 is in accordance with the 16-bit compare-match conditions. ? control of output from the tmo1 pin by bits os3 to os0 in tcsr1 is in accordance with the lower 8-bit compare-match conditions. compare-match count mode: when bits cks2 to cks0 in tcr1 are b'100, tcnt1 counts compare-match as for channel 0. channels 0 and 1 are controlled independently. conditions such as setting of the cmf flag, generation of interrupts, output from the tmo pin, and counter clearing are in accordance with the settings for each channel. usage note: if the 16-bit count mode and compare-match count mode are set simultaneously, the input clock pulses for tcnt0 and tcnt1 are not generated and thus the counters will stop operating. simultaneous setting of these two modes should therefore be avoided.
354 12.4 interrupt sources the tmr0, tmr1, and tmry 8-bit timers can generate three types of interrupt: compare- match a and b (cmia and cmib), and overflow (ovi). tmrx can generate only an icix interrupt. an interrupt is requested when the corresponding interrupt enable bit is set in tcr or tcsr. independent signals are sent to the interrupt controller for each interrupt. it is also possible to activate the dtc by means of cmia and cmib interrupts from tmr0, tmr1 and tmry. an overview of 8-bit timer interrupt sources is given in tables 12.3 to 12.5. table 12.3 tmr0 and tmr1 8-bit timer interrupt sources interrupt source description dtc activation interrupt priority cmia requested by cmfa possible high cmib requested by cmfb possible ovi requested by ovf not possible low table 12.4 tmrx 8-bit timer interrupt source interrupt source description dtc activation icix requested by icf not possible table 12.5 tmry 8-bit timer interrupt sources interrupt source description dtc activation interrupt priority cmia requested by cmfa possible high cmib requested by cmfb possible ovi requested by ovf not possible low
355 12.5 8-bit timer application example in the example below, the 8-bit timer is used to generate a pulse output with a selected duty cycle, as shown in figure 12.9. the control bits are set as follows: in tcr, cclr1 is cleared to 0 and cclr0 is set to 1 so that the timer counter is cleared by a tcora compare-match. in tcsr, bits os3 to os0 are set to b'0110, causing 1 output at a tcora compare-match and 0 output at a tcorb compare-match. with these settings, the 8-bit timer provides output of pulses at a rate determined by tcora with a pulse width determined by tcorb. no software intervention is required. tcnt h'ff counter clear tcora tcorb h'00 tmo figure 12.9 pulse output (example)
356 12.6 usage notes application programmers should note that the following kinds of contention can occur in the 8- bit timer module. 12.6.1 contention between tcnt write and clear if a timer counter clock pulse is generated during the t2 state of a tcnt write cycle, the clear takes priority, so that the counter is cleared and the write is not performed. figure 12.10 shows this operation. address tcnt address internal write signal counter clear signal tcnt n h'00 t 1 t 2 tcnt write cycle by cpu figure 12.10 contention between tcnt write and clear
357 12.6.2 contention between tcnt write and increment if a timer counter clock pulse is generated during the t2 state of a tcnt write cycle, the write takes priority and the counter is not incremented. figure 12.11 shows this operation. address tcnt address internal write signal tcnt input clock tcnt nm t 1 t 2 tcnt write cycle by cpu counter write data figure 12.11 contention between tcnt write and increment
358 12.6.3 contention between tcor write and compare-match during the t2 state of a tcor write cycle, the tcor write has priority even if a compare- match occurs and the compare-match signal is disabled. figure 12.12 shows this operation. with tmrx, an icr input capture contends with a compare-match in the same way as with a write to tcorc. in this case, the input capture has priority and the compare-match signal is inhibited. address tcor address internal write signal tcnt tcor nm t 1 t 2 tcor write cycle by cpu tcor write data n n + 1 compare-match signal inhibited figure 12.12 contention between tcor write and compare-match
359 12.6.4 contention between compare-matches a and b if compare-matches a and b occur at the same time, the 8-bit timer operates in accordance with the priorities for the output states set for compare-match a and compare-match b, as shown in table 12.6. table 12.6 timer output priorities output setting priority toggle output high 1 output 0 output no change low 12.6.5 switching of internal clocks and tcnt operation tcnt may increment erroneously when the internal clock is switched over. table 12.7 shows the relationship between the timing at which the internal clock is switched (by writing to the cks1 and cks0 bits) and the tcnt operation when the tcnt clock is generated from an internal clock, the falling edge of the internal clock pulse is detected. if clock switching causes a change from high to low level, as shown in no. 3 in table 12.7, a tcnt clock pulse is generated on the assumption that the switchover is a falling edge. this increments tcnt. erroneous incrementation can also happen when switching between internal and external clocks.
360 table 12.7 switching of internal clock and tcnt operation no. timing of switchover by means of cks1 and cks0 bits tcnt clock operation 1 switching from low to low * 1 clock before switchover clock after switchover tcnt clock tcnt cks bit rewrite n n + 1 2 switching from low to high * 2 clock before switchover clock after switchover tcnt clock tcnt cks bit rewrite n n + 1 n + 2
361 table 12.7 switching of internal clock and tcnt operation (cont) no. timing of switchover by means of cks1 and cks0 bits tcnt clock operation 3 switching from high to low * 3 clock before switchover clock after switchover tcnt clock tcnt cks bit rewrite n n + 1 n + 2 * 4 4 switching from high to high clock before switchover clock after switchover tcnt clock tcnt cks bit rewrite n n + 1 n + 2 notes: 1. includes switching from low to stop, and from stop to low. 2. includes switching from stop to high. 3. includes switching from high to stop. 4. generated on the assumption that the switchover is a falling edge; tcnt is incremented.
362
363 section 13 timer connection [h8s/2148 series] provided in the h8s/2148 series; not provided in the h8s/2144 series. 13.1 overview the h8s/2148 series allows interconnection between a combination of input signals, the input/output of the single free-running timer (frt) channel and the three 8-bit timer channels (tmr1, tmrx, and tmry). this capability can be used to implement complex functions such as pwm decoding and clamp waveform output. all the timers are initially set for independent operation. 13.1.1 features the features of the timer connection facility are as follows. five input pins and four output pins, all of which can be designated for phase inversion. positive logic is assumed for all signals used within the timer connection facility. an edge-detection circuit is connected to the input pins, simplifying signal input detection. tmrx can be used for pwm input signal decoding and clamp waveform generation. an external clock signal divided by tmr1 can be used as the frt capture input signal. an internal synchronization signal can be generated using the frt and tmry. a signal generated/modified using an input signal and timer connection can be selected and output.
364 13.1.2 block diagram figure 13.1 shows a block diagram of the timer connection facility. edge detection edge detection vsynci/ ftia/tmiy vfbacki/ ftib ftic ftid phase inversion phase inversion phase inversion phase inversion phase inversion phase inversion ivi signal selection read flag edge detection edge detection edge detection phase inversion phase inversion phase inversion read flag ivi signal frt input selec- tion set sync res vsync modify ftia ftib ftic ftid 16-bit frt ocra +vr, +vf icrd +1m, +2m compare match ftoa cma(r) cma(f) ftob cm2m cm1m res set 2f h mask generation 2f h mask/flag cblank waveform generation tmr1 input selection tmci 8-bit tmr1 tmri cmb tmo set ivg signal ivo signal res vsync generation ivo signal selection tmiy signal selection frt output selection vsynco/ ftoa tmri/tmci tmo 8-bit tmry ihg signal cblank hsynco/ tmo1 tmox tmo1 output selection iho signal selection cl4 generation cl4 signal clampo/ ftic cl signal selection pdc signal pwm decoding 8-bit tmrx cmb tmo cma icr icr +1c compare match clamp waveform generation tmci tmri cm1c cl1 signal cl2 signal cl3 signal ihi signal ihi signal selection hsynci/ tmci1 csynci/ tmri1 hfbacki/ ftci/tmix figure 13.1 block diagram of timer connection facility
365 13.1.3 input and output pins table 13.1 lists the timer connection input and output pins. table 13.1 timer connection input and output pins name abbreviation input/ output function vertical synchronization signal input pin vsynci input vertical synchronization signal input pin or ftia input pin/tmiy input pin horizontal synchronization signal input pin hsynci input horizontal synchronization signal input pin or tmci1 input pin composite synchronization signal input pin csynci input composite synchronization signal input pin or tmri1 input pin spare vertical synchronization signal input pin vfbacki input spare vertical synchronization signal input pin or ftib input pin spare horizontal synchronization signal input pin hfbacki input spare horizontal synchronization signal input pin or ftci input pin/tmix input pin vertical synchronization signal output pin vsynco output vertical synchronization signal output pin or ftoa output pin horizontal synchronization signal output pin hsynco output horizontal synchronization signal output pin or tmo1 output pin clamp waveform output pin clampo output clamp waveform output pin or ftic input pin blanking waveform output pin cblank output blanking waveform output pin
366 13.1.4 register configuration table 13.2 lists the timer connection registers. timer connection registers can only be accessed when the hie bit in syscr is 0. table 13.2 register configuration name abbreviation r/w initial value address * 1 timer connection register i tconri r/w h'00 h'fffc timer connection register o tconro r/w h'00 h'fffd timer connection register s tconrs r/w h'00 h'fffe edge sense register sedgr r/(w) * 2 h'00 * 3 h'ffff module stop control register mstprh r/w h'3f h'ff86 mstprl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. bits 7 to 2: only 0 can be written to clear the flags. 3. bits 1 and 0: undefined (reflect the pin states).
367 13.2 register descriptions 13.2.1 timer connection register i (tconri) bit initial value read/write 7 simod1 0 r/w 6 simod0 0 r/w 5 scone 0 r/w 4 icst 0 r/w 3 hfinv 0 r/w 0 viinv 0 r/w 2 vfinv 0 r/w 1 hiinv 0 r/w tconri is an 8-bit readable/writable register that controls connection between timers, the signal source for synchronization signal input, phase inversion, etc. tconr1 is initialized to h'00 by a reset and in hardware standby mode. bits 7 and 6input synchronization mode select 1 and 0 (simod1, simod0): these bits select the signal source of the ihi and ivi signals. bit 7 bit 6 description simod1 simod0 mode ihi signal ivi signal 0 0 no signal (initial value) hfbacki input vfbacki input 1 s-on-g mode csynci input pdc input 1 0 composite mode hsynci input pdc input 1 separate mode hsynci input vsynci input bit 5synchronization signal connection enable (scone): selects the signal source of the frt fti input and the tmr1 tmci1/tmri1 input. bit 5 description scone mode ftia ftib ftic ftid tmci1 tmri1 0 normal connection (initial value) ftia input ftib input ftic input ftid input tmci1 input tmri1 input 1 synchronization signal connection mode ivi signal tmo1 signal vfbacki input ihi signal ihi signal ivi inverse signal
368 bit 4input capture start bit (icst): the tmrx external reset input (tmrix) is connected to the ihi signal. tmrx has input capture registers (ticr, ticrr, and ticrf). ticrr and ticrf can measure the width of a short pulse by means of a single capture operation under the control of the icst bit. when a rising edge followed by a falling edge is detected on tmrix after the icst bit is set to 1, the contents of tcnt at those points are captured into ticrr and ticrf, respectively, and the icst bit is cleared to 0. bit 4 icst description 0 the ticrr and ticrf input capture functions are stopped [clearing condition] when a rising edge followed by a falling edge is detected on tmrix (initial value) 1 the ticrr and ticrf input capture functions are operating (waiting for detection of a rising edge followed by a falling edge on tmrix) [setting condition] when 1 is written in icst after reading icst = 0 bits 3 to 0input synchronization signal inversion (hfinv, vfinv, hiinv, viinv): these bits select inversion of the input phase of the spare horizontal synchronization signal (hfbacki), the spare vertical synchronization signal (vfbacki), the horizontal synchronization signal and composite synchronization signal (hsynci, csynci), and the vertical synchronization signal (vsynci). bit 3 hfinv description 0 the hfbacki pin state is used directly as the hfbacki input (initial value) 1 the hfbacki pin state is inverted before use as the hfbacki input bit 2 vfinv description 0 the vfbacki pin state is used directly as the vfbacki input (initial value) 1 the vfbacki pin state is inverted before use as the vfbacki input
369 bit 1 hiinv description 0 the hsynci and csynci pin states are used directly as the hsynci and csynci inputs (initial value) 1 the hsynci and csynci pin states are inverted before use as the hsynci and csynci inputs bit 0 viinv description 0 the vsynci pin state is used directly as the vsynci input (initial value) 1 the vsynci pin state is inverted before use as the vsynci input
370 13.2.2 timer connection register o (tconro) bit initial value read/write 7 hoe 0 r/w 6 voe 0 r/w 5 cloe 0 r/w 4 cboe 0 r/w 3 hoinv 0 r/w 0 cboinv 0 r/w 2 voinv 0 r/w 1 cloinv 0 r/w tconro is an 8-bit readable/writable register that controls output signal output, phase inversion, etc. tconro is initialized to h'00 by a reset and in hardware standby mode. bits 7 and 4output enable (hoe, voe, cloe, cboe): these bits control enabling/disabling of horizontal synchronization signal (hsynco), vertical synchronization signal (vsynco), clamp waveform (clampo), and blanking waveform (cblank) output. when output is disabled, the state of the relevant pin is determined by the port dr and ddr, frt, tmr, and pwm settings. output enabling/disabling control does not affect the port, frt, or tmr input functions, but some frt and tmr input signal sources are determined by the scone bit in tconri. bit 7 hoe description 0 the p44/tmo1/hirq1/hsynco pin functions as the p44/tmo1/ hirq1 pin (initial value) 1 the p44/tmo1/hirq1/hsynco pin functions as the hsynco pin bit 6 voe description 0 the p61/ftoa/ .,1 /cin1/vsynco pin functions as the p61/ftoa/ .,1 /cin1 pin (initial value) 1 the p61/ftoa/ .,1 /cin1/vsynco pin functions as the vsynco pin bit 5 cloe description 0 the p64/ftic/ .,1 /cin4/clampo pin functions as the p64/ftic/ .,1 /cin4 pin (initial value) 1 the p64/ftic/ .,1 /cin4/clampo pin functions as the clampo pin
371 bit 4 cboe description 0 the p27/a15/pw15/cblank pin functions as the p27/a15/pw15 pin (initial value) 1 in mode 1 (expanded mode with on-chip rom disabled): the p27/a15/pw15/cblank pin functions as the a15 pin in modes 2 and 3 (modes with on-chip rom enabled): the p27/a15/pw15/cblank pin functions as the cblank pin bits 3 to 0output synchronization signal inversion (hoinv, voinv, cloinv, cboinv): these bits select inversion of the output phase of the horizontal synchronization signal (hsynco), the vertical synchronization signal (vsynco), the clamp waveform (clampo), and the blank waveform (cblank). bit 3 hoinv description 0 the iho signal is used directly as the hsynco output (initial value) 1 the iho signal is inverted before use as the hsynco output bit 2 voinv description 0 the ivo signal is used directly as the vsynco output (initial value) 1 the ivo signal is inverted before use as the vsynco output bit 1 cloinv description 0 the clo signal (cl1, cl2, cl3, or cl4 signal) is used directly as the clampo output (initial value) 1 the clo signal (cl1, cl2, cl3, or cl4 signal) is inverted before use as the clampo output bit 0 cboinv description 0 the cblank signal is used directly as the cblank output (initial value) 1 the cblank signal is inverted before use as the cblank output
372 13.2.3 timer connection register s (tconrs) bit initial value read/write 7 tmrx/y 0 r/w 6 isgene 0 r/w 5 homod1 0 r/w 4 homod0 0 r/w 3 vomod1 0 r/w 0 clmod0 0 r/w 2 vomod0 0 r/w 1 clmod1 0 r/w tconrs is an 8-bit readable/writable register that selects 8-bit timer tmrx/tmry access and the synchronization signal output signal source and generation method. tconrs is initialized to h'00 by a reset and in hardware standby mode. bit 7tmrx/tmry access select (tmrx/y): the tmrx and tmry registers can only be accessed when the hie bit in syscr is cleared to 0. in the h8s/2148 series, some of the tmrx registers and the tmry registers are assigned to the same memory space addresses (h'fff0 to h'fff5), and the tmrx/y bit determines which registers are accessed. in the h8s/2144 series, there is no control of tmry register access by this bit. bit 7 tmrx/y description 0 the tmrx registers are accessed at addresses h'fff0 to h'fff5 (initial value) 1 the tmry registers are accessed at addresses h'fff0 to h'fff5
373 bit 6internal synchronization signal select (isgene): selects internal synchronization signals (ihg, ivg, and cl4 signals) as the signal sources for the iho, ivo, and clo signals. bits 5 and 4horizontal synchronization output mode select 1 and 0 (homod1, homod0): these bits select the signal source and generation method for the iho signal. bit 6 bit 5 bit 4 isgene vomod1 vomod0 description 0 0 0 the ihi signal (without 2fh modification) is selected (initial value) 1 the ihi signal (with 2fh modification) is selected 1 0 the cl1 signal is selected 1 1 0 0 the ihg signal is selected 1 10 1 bits 3 and 2vertical synchronization output mode select 1 and 0 (vomod1, vomod0): these bits select the signal source and generation method for the ivo signal. bit 6 bit 3 bit 2 isgene vomod1 vomod0 description 0 0 0 the ivi signal (without fall modification or ihi synchronization) is selected (initial value) 1 the ivi signal (without fall modification, with ihi synchronization) is selected 1 0 the ivi signal (with fall modification, without ihi synchronization) is selected 1 the ivi signal (with fall modification and ihi synchronization) is selected 1 0 0 the ivg signal is selected 1 10 1
374 bits 1 and 0clamp waveform mode select 1 and 0 (clmod1, clmod0): these bits select the signal source for the clo signal (clamp waveform). bit 6 bit 1 bit 0 isgene clmod1 clmod2 description 0 0 0 the cl1 signal is selected (initial value) 1 the cl2 signal is selected 1 0 the cl3 signal is selected 1 1 0 0 the cl4 signal is selected 1 10 1 13.2.4 edge sense register (sedgr) bit initial value read/write notes: 1. only 0 can be written, to clear the flags. 2. the initial value is undefined since it depends on the pin states. 7 vedg 0 r/(w) 6 hedg 0 r/(w) 5 cedg 0 r/(w) 4 hfedg 0 r/(w) 3 vfedg 0 r/(w) 0 ivi * 2 r 2 preqf 0 r/(w) 1 ihi * 2 r * 1 * 1 * 1 * 1 * 1 * 1 sedgr is an 8-bit readable/writable register used to detect a rising edge on the timer connection input pins and the occurrence of 2fh modification, and to determine the phase of the ivi and ihi signals. the upper 6 bits of sedgr are initialized to 0 by a reset and in hardware standby mode. the initial value of the lower 2 bits is undefined, since it depends on the pin states.
375 bit 7vsynci edge (vedg): detects a rising edge on the vsynci pin. bit 7 vedg description 0 [clearing condition] when 0 is written in vedg after reading vedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the vsynci pin bit 6hsynci edge (hedg): detects a rising edge on the hsynci pin. bit 6 hedg description 0 [clearing condition] when 0 is written in hedg after reading hedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the hsynci pin bit 5csynci edge (cedg): detects a rising edge on the csynci pin. bit 5 cedg description 0 [clearing condition] when 0 is written in cedg after reading cedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the csynci pin bit 4hfbacki edge (hfedg): detects a rising edge on the hfbacki pin. bit 4 hfedg description 0 [clearing condition] when 0 is written in hfedg after reading hfedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the hfbacki pin
376 bit 3vfbacki edge (vfedg): detects a rising edge on the vfbacki pin. bit 3 vfedg description 0 [clearing condition] when 0 is written in vfedg after reading vfedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the vfbacki pin bit 2pre-equalization flag (preqf): detects the occurrence of an ihi signal 2fh modification condition. the generation of a falling/rising edge in the ihi signal during a mask interval is expressed as the occurrence of a 2fh modification condition. for details, see section 13.3.4, ihi signal 2fh modification. bit 2 preqf description 0 [clearing condition] when 0 is written in preqf after reading preqf = 1 (initial value) 1 [setting condition] when an ihi signal 2fh modification condition is detected bit 1ihi signal level (ihi): indicates the current level of the ihi signal. signal source and phase inversion selection for the ihi signal depends on the contents of tconri. read this bit to determine whether the input signal is positive or negative, then maintain the ihi signal at positive phase by modifying tconri. bit 1 ihi description 0 the ihi signal is low 1 the ihi signal is high bit 0ivi signal level (ivi): indicates the current level of the ivi signal. signal source and phase inversion selection for the ivi signal depends on the contents of tconri. read this bit to determine whether the input signal is positive or negative, then maintain the ivi signal at positive phase by modifying tconri. bit 0 ivi description 0 the ivi signal is low 1 the ivi signal is high
377 13.2.5 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp13, mstp12, and mstp8 bits are set to 1, the 16-bit free-running timer, 8-bit timer channels 0 and 1, and 8-bit timer channels x and y and timer connection, respectively, halt and enter module stop mode. see section 24.5., module stop mode, for details. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 5module stop (mstp13): specifies frt module stop mode. mstpcrh bit 5 mstp13 description 0 frt module stop mode is cleared 1 frt module stop mode is set (initial value) mstpcrh bit 4module stop (mstp12): specifies 8-bit timer channel 0 and 1 module stop mode. mstpcrh bit 4 mstp12 description 0 8-bit timer channel 0 and 1 module stop mode is cleared 1 8-bit timer channel 0 and 1 module stop mode is set (initial value)
378 mstpcrh bit 0module stop (mstp8): specifies 8-bit timer channel x and y and timer connection module stop mode. mstpcrh bit 0 mstp8 description 0 8-bit timer channel x and y and timer connection module stop mode is cleared 1 8-bit timer channel x and y and timer connection module stop mode is set (initial value) 13.3 operation 13.3.1 pwm decoding (pdc signal generation) the timer connection facility and tmrx can be used to decode a pwm signal in which 0 and 1 are represented by the pulse width. to do this, a signal in which a rising edge is generated at regular intervals must be selected as the ihi signal. the timer counter (tcnt) in tmrx is set to count the internal clock pulses and to be cleared on the rising edge of the external reset signal (ihi signal). the value to be used as the threshold for deciding the pulse width is written in tcorb. the pwm decoder contains a delay latch which uses the ihi signal as data and compare-match signal b (cmb) as a clock, and the state of the ihi signal (the result of the pulse width decision) at the compare-match signal b timing after tcnt is reset by the rise of the ihi signal is output as the pdc signal. the pulse width setting using ticrr and ticrf of tmrx can be used to determine the pulse width decision threshold. examples of tcr and tcorb settings are shown in tables 13.3 and 13.4, and the timing chart is shown in figure 13.2. table 13.3 examples of tcr settings bit(s) abbreviation contents description 7 6 5 cmieb cmiea ovie 0 0 0 interrupts due to compare-match and overflow are disabled 4 and 3 cclr1, cclr0 11 tcnt is cleared by the rising edge of the external reset signal (ihi signal) 2 to 0 cks2 to cks0 001 incremented on internal clock: ?
379 table 13.4 examples of tcorb (pulse width threshold) settings ?:10 mhz ?: 12 mhz ?: 16 mhz ?: 20 mhz h'07 0.8 s 0.67 s 0.5 s 0.4 s h'0f 1.6 s 1.33 s 1 s 0.8 s h'1f 3.2 s 2.67 s 2 s 1.6 s h'3f 6.4 s 5.33 s 4 s 3.2 s h'7f 12.8 s 10.67 s 8 s 6.4 s ihi signal pdc signal tcnt tcorb (threshold) figure 13.2 timing chart for pwm decoding
380 13.3.2 clamp waveform generation (cl1/cl2/cl3 signal generation) the timer connection facility and tmrx can be used to generate signals with different duty cycles and rising/falling edges (clamp waveforms) in synchronization with the input signal (ihi signal). three clamp waveforms can be generated: the cl1, cl2, and cl3 signals. in addition, the cl4 signal can be generated using tmry. the cl1 signal rises simultaneously with the rise of the ihi signal, and when the cl1 signal is high, the cl2 signal rises simultaneously with the fall of the ihi signal. the fall of both the cl1 and the cl2 signal can be specified by tcora. the rise of the cl3 signal can be specified as simultaneous with the sampling of the fall of the ihi signal using the system clock, and the fall of the cl3 signal can be specified by tcorc. the cl3 signal can also fall when the ihi signal rises. tcnt in tmrx is set to count internal clock pulses and to be cleared on the rising edge of the external reset signal (ihi signal). the value to be used as the cl1 signal pulse width is written in tcora. write a value of h'02 or more in tcora when internal clock ? is selected as the tmrx counter clock, and a value or h'01 or more when ?/2 is selected. when internal clock ? is selected, the cl1 signal pulse width is (tcora set value + 3 0.5). when the cl2 signal is used, the setting must be made so that this pulse width is greater than the ihi signal pulse width. the value to be used as the cl3 signal pulse width is written in tcorc. the ticr register in tmrx captures the value of tcnt at the inverse of the external reset signal edge (in this case, the falling edge of the ihi signal). the timing of the fall of the cl3 signal is determined by the sum of the contents of ticr and tcorc. caution is required if the rising edge of the ihi signal precedes the fall timing set by the contents of tcorc, since the ihi signal will cause the cl3 signal to fall. examples of tmrx tcr settings are the same as those in table 13.3. the clamp waveform timing charts are shown in figures 13.3 and 13.4. since the rise of the cl1 and cl2 signals is synchronized with the edge of the ihi signal, and their fall is synchronized with the system clock, the pulse width variation is equivalent to the resolution of the system clock. both the rise and the fall of the cl3 signal are synchronized with the system clock and the pulse width is fixed, but there is a variation in the phase relationship with the ihi signal equivalent to the resolution of the system clock.
381 ihi signal cl1 signal cl2 signal tcnt tcora figure 13.3 timing chart for clamp waveform generation (cl1 and cl2 signals) ihi signal cl3 signal tcnt ticr+tcorc ticr figure 13.4 timing chart for clamp waveform generation (cl3 signal)
382 13.3.3 measurement of 8-bit timer divided waveform period the timer connection facility, tmr1, and the free-running timer (frt) can be used to measure the period of an ihi signal divided waveform. since tmr1 can be cleared by a rising edge of the ivi signal, the rise and fall of the ihi signal divided waveform can be virtually synchronized with the ivi signal. this enables period measurement to be carried out efficiently. to measure the period of an ihi signal divided waveform, tcnt in tmr1 is set to count the external clock (ihi signal) pulses and to be cleared on the rising edge of the external reset signal (ivi signal). the value to be used as the division factor is written in tcora, and the tmo output method is specified by the os bits in tcsr. examples of tcr and tcsr settings are shown in table 13.5, and the timing chart for measurement of the ivi signal and ihi signal divided waveform periods is shown in figure 13.5. the period of the ihi signal divided waveform is given by (icrd(3) C icrd(2)) the resolution. table 13.5 examples of tcr and tcsr settings register bit(s) abbreviation contents description tcr in tmr1 7 cmieb 0 interrupts due to compare-match and overflow are disabled 6 cmiea 0 5 ovie 0 4 and 3 cclr1, cclr0 11 tcnt is cleared by the rising edge of the external reset signal (ivi signal) 2 to 0 cks2 to cks0 101 tcnt is incremented on the rising edge of the external clock (ihi signal) tcsr in tmr1 3 to 0 os3 to os0 0011 not changed by compare-match b; output inverted by compare-match a (toggle output): division by 512 1001 or when tcorb < tcora, 1 output on compare-match b, and 0 output on compare-match a: division by 256 tcr in frt 6 iedgb 0/1 0: frc value is transferred to icrb on falling edge of input capture input b (ihi divided signal waveform) 1: frc value is transferred to icrb on rising edge of input capture input b (ihi divided signal waveform) 1 and 0 cks1, cks0 01 frc is incremented on internal clock: ?/8 tcsr in frt 0 cclra 0 frc clearing is disabled
383 ivi signal ihi signal divided waveform frc icrb icrb(1) icrb(2) icrb(3) icrb(4) figure 13.5 timing chart for measurement of ivi signal and ihi signal divided waveform periods 13.3.4 ihi signal and 2fh modification by using the timer connection frt, even if there is a part of the ihi signal with twice the frequency, this can be eliminated. in order for this function to operate properly, the duty cycle of the ihi signal must be approximately 30% or less, or approximately 70% or above. the 8-bit ocrdm contents or twice the ocrdm contents can be added automatically to the data captured in icrd in the frt, and compare-matches generated at these points. the interval between the two compare-matches is called a mask interval. a value equivalent to approximately 1/3 the ihi signal period is written in ocrdm. icrd is set so that capture is performed on the rise of the ihi signal. since the ihi signal supplied to the iho signal selection circuit is normally set on the rise of the ihi signal and reset on the fall, its waveform is the same as that of the original ihi signal. when 2fh modification is selected, ihi signal edge detection is disabled during mask intervals. capture is also disabled during these intervals. examples of frt tcr settings are shown in table 13.6, and the 2fh modification timing chart is shown in figure 13.6.
384 table 13.6 examples of tcr, tcsr, tcor, and ocrdm settings register bit(s) abbreviation contents description tcr in frt 4 iedgd 1 frc value is transferred to icrd on the rising edge of input capture input d (ihi signal) 1 and 0 cks1, cks0 01 frc is incremented on internal clock: ?/8 tcsr in frt 0 cclra 0 frc clearing is disabled tcor in frt 7 icrdms 1 icrd is set to the operating mode in which ocrdm is used ocrdm in frt 7 to 0 ocrdm7 to 0 h'01 to h'ff specifies the period during which icrd operation is masked ihi signal (without 2fh modification) ihi signal (with 2fh modification) mask interval icrd + ocrdm 2 icrd + ocrdm frc icrd figure 13.6 2fh modification timing chart
385 13.3.5 ivi signal fall modification and ihi synchronization by using the timer connection tmr1, the fall of the ivi signal can be shifted backward by the specified number of ihi signal waveforms. also, the fall of the ivi signal can be synchronized with the rise of the ihi signal. to perform 8-bit timer divided waveform period measurement, tcnt in tmr1 is set to count external clock (ihi signal) pulses, and to be cleared on the rising edge of the external reset signal (inverse of the ivi signal). the number of ihi signal pulses until the fall of the ivi signal is written in tcorb. since the ivi signal supplied to the ivo signal selection circuit is normally set on the rise of the ivi signal and reset on the fall, its waveform is the same as that of the original ivi signal. when fall modification is selected, a reset is performed on a tmr1 tcorb compare-match. the fall of the waveform generated in this way can be synchronized with the rise of the ihi signal, regardless of whether or not fall modification is selected. examples of tmr1 tcorb, tcr, and tcsr settings are shown in table 13.7, and the fall modification/ihi synchronization timing chart is shown in figure 13.7. table 13.7 examples of tcorb, tcr, and tcsr settings register bit(s) abbreviation contents description tcr in tmr1 7 cmieb 0 interrupts due to compare-match and overflow are disabled 6 cmiea 0 5 ovie 0 4 and 3 cclr1, cclr0 11 tcnt is cleared by the rising edge of the external reset signal (inverse of the ivi signal) 2 to 0 cks2 to cks0 101 tcnt is incremented on the rising edge of the external clock (ihi signal) tcsr in tmr1 3 to 0 os3 to os0 0011 not changed by compare-match b; output inverted by compare-match a (toggle output) 1001 or when tcorb tcora, 1 output on compare-match b, 0 output on compare- match a tocrb in tmr1 h'03 (example) compare-match on the 4th (example) rise of the ihi signal after the rise of the inverse of the ivi signal
386 0 1 2 3 4 5 tcnt tcnt = tcorb (3) ihi signal ivi signal (pdc signal) ivo signal (without fall modification, with ihi synchronization) ivo signal (with fall modification, without ihi synchronization) ivo signal (with fall modification and ihi synchronization) figure 13.7 fall modification/ihi synchronization timing chart 13.3.6 internal synchronization signal generation (ihg/ivg/cl4 signal generation) by using the timer connection frt and tmry, it is possible to automatically generate internal signals (ihg and ivg signals) corresponding to the ihi and ivi signals. as the ihg signal is synchronized with the rise of the ivg signal, the ihg signal period must be made a divisor of the ivg signal period in order to keep it constant. in addition, the cl4 signal can be generated in synchronization with the ihg signal. the contents of ocra in the frt are updated by the automatic addition of the contents of ocrar or ocraf, alternately, each time a compare-match occurs. a value corresponding to the 0 interval of the ivg signal is written in ocrar, and a value corresponding to the 1 interval of the ivg signal is written in ocraf. the ivg signal is set by a compare-match after an ocrar addition, and reset by a compare-match after an ocraf addition. the ihg signal is the tmry 8-bit timer output. tmry is set to count internal clock pulses, and to be cleared on tcora compare-match, to fix the period and set the timer output. tcorb is set so as to reset the timer output. the ivg signal is connected as the tmry reset input (tmri), and the rise of the ivg signal can be treated in the same way as a tcora compare- match. the cl4 signal is a waveform that rises within one system clock period after the fall of the ihg signal, and has a 1 interval of 6 system clock periods. examples of settings of tcora, tcorb, tcr, and tcsr in tmry, and ocrar, ocraf, and tcr in the frt, are shown in table 13.8, and the ihg signal/ivg signal timing chart is shown in figure 13.8.
387 table 13.8 examples of ocrar, ocraf, tocr, tcora, tcorb, tcr, and tcsr settings register bit(s) abbreviation contents description tcr in tmry 7 cmieb 0 interrupts due to compare-match and overflow are disabled 6 cmiea 0 5 ovie 0 4 and 3 cclr1, cclr0 01 tcnt is cleared by compare-match a 2 to 0 cks2 to cks0 001 tcnt is incremented on internal clock: ?/4 tcsr in tmry 3 to 0 os3 to os0 0110 0 output on compare-match b 1 output on compare-match a tocra in tmry h'3f (example) ihg signal period = ? 256 tocrb in tmry h'03 (example) ihg signal 1 interval = ? 16 tcr in frt 1 and 0 cks1, cks0 01 frc is incremented on internal clock: ?/8 ocrar in frt h'7fef (example) ivg signal 0 interval = ? 262016 ivg signal period = ? 262144 (1024 times ihg signal) ocraf in frt h'000f (example) ivg signal 1 interval = ? 128 tocr in frt 6 ocrams 1 ocra is set to the operating mode in which ocrar and ocraf are used
388 6 system clocks 6 system clocks 6 system clocks ocra (4) = ocra (3) + ocrar ocra (3) = ocra (2) + ocraf ocra (2) = ocra (1) + ocrar ocra (1) = ocra (0) + ocraf ocra frc cl4 signal ihg signal tcora tcorb tcnt ivg signal figure 13.8 ivg signal/ihg signal/cl4 signal timing chart
389 13.3.7 hsynco output with the hsynco output, the meaning of the signal source to be selected and use or non-use of modification varies according to the ihi signal source and the waveform required by external circuitry. the meaning of the hsynco output in each mode is shown in table 13.9. table 13.9 meaning of hsynco output in each mode mode ihi signal iho signal meaning of iho signal no signal hfbacki input ihi signal (without 2fh modification) hfbacki input is output directly ihi signal (with 2fh modification) meaningless unless there is a double-frequency part in the hfbacki input cl1 signal hfbacki input 1 interval is changed before output ihg signal internal synchronization signal is output s-on-g mode csynci input ihi signal (without 2fh modification) csynci input (composite synchronization signal) is output directly ihi signal (with 2fh modification) double-frequency part of csynci input (composite synchronization signal) is eliminated before output cl1 signal csynci input (composite synchronization signal) horizontal synchronization signal part is separated before output ihg signal internal synchronization signal is output composite mode hsynci input ihi signal (without 2fh modification) hsynci input (composite synchronization signal) is output directly ihi signal (with 2fh modification) double-frequency part of hsynci input (composite synchronization signal) is eliminated before output cl1 signal hsynci input (composite synchronization signal) horizontal synchronization signal part is separated before output ihg signal internal synchronization signal is output separate mode hsynci input ihi signal (without 2fh modification) hsynci input (horizontal synchronization signal) is output directly ihi signal (with 2fh modification) meaningless unless there is a double-frequency part in the hsynci input (horizontal synchronization signal) cl1 signal hsynci input (horizontal synchronization signal) 1 interval is changed before output ihg signal internal synchronization signal is output
390 13.3.8 vsynco output with the vsynco output, the meaning of the signal source to be selected and use or non-use of modification varies according to the ivi signal source and the waveform required by external circuitry. the meaning of the vsynco output in each mode is shown in table 13.10. table 13.10 meaning of vsynco output in each mode mode ivi signal ivo signal meaning of ivo signal no signal vfbacki input ivi signal (without fall modification or ihi synchronization) vfbacki input is output directly ivi signal (without fall modification, with ihi synchronization) meaningless unless vfbacki input is synchronized with hfbacki input ivi signal (with fall modification, without ihi synchronization) vfbacki input fall is modified before output ivi signal (with fall modification and ihi synchronization) vfbacki input fall is modified and signal is synchronized with hfbacki input before output ivg signal internal synchronization signal is output s-on-g mode or composite mode pdc signal ivi signal (without fall modification or ihi synchronization) csynci/hsynci input (composite synchronization signal) vertical synchronization signal part is separated before output ivi signal (without fall modification, with ihi synchronization) csynci/hsynci input (composite synchronization signal) vertical synchronization signal part is separated, and signal is synchronized with csynci/hsynci input before output ivi signal (with fall modification, without ihi synchronization) csynci/hsynci input (composite synchronization signal) vertical synchronization signal part is separated, and fall is modified before output ivi signal (with fall modification and ihi synchronization) csynci/hsynci input (composite synchronization signal) vertical synchronization signal part is separated, fall is modified, and signal is synchronized with csynci/hsynci input before output ivg signal internal synchronization signal is output
391 table 13.10 meaning of vsynco output in each mode (cont) mode ivi signal ivo signal meaning of ivo signal separate mode vsynci input ivi signal (without fall modification or ihi synchronization) vsynci input (vertical synchronization signal) is output directly ivi signal (without fall modification, with ihi synchronization) meaningless unless vsynci input (vertical synchronization signal) is synchronized with hsynci input (horizontal synchronization signal) ivi signal (with fall modification, without ihi synchronization) vsynci input (vertical synchronization signal) fall is modified before output ivi signal (with fall modification and ihi synchronization) vsynci input (vertical synchronization signal) fall is modified and signal is synchronized with hsynci input (horizontal synchronization signal) before output ivg signal internal synchronization signal is output 13.3.9 cblank output using the signals generated/selected with timer connection, it is possible to generate a waveform based on the composite synchronization signal (blanking waveform). one kind of blanking waveform is generated by combining hfbacki and vfbacki inputs, with the phase polarity made positive by means of bits hfinv and vfinv in tconri, with the ivo signal. the composition logic is shown in figure 13.9. reset set cblank signal (positive) hfbacki input (positive) vfbacki input (positive) ivo signal (positive) q falling edge sensing rising edge sensing figure 13.9 cblank output waveform generation
392
393 section 14 watchdog timer (wdt) 14.1 overview the h8s/2148 series and h8s/2144 series have an on-chip watchdog timer with two channels (wdt0, wdt1) for monitoring system operation. the wdt outputs an overflow signal ( 5(62 ) if a system crash prevents the cpu from writing to the timer counter, allowing it to overflow. at the same time, the wdt can also generate an internal reset signal or internal nmi interrupt signal. when this watchdog function is not needed, the wdt can be used as an interval timer. in interval timer mode, an interval timer interrupt is generated each time the counter overflows. 14.1.1 features wdt features are listed below. switchable between watchdog timer mode and interval timer mode internal reset or internal interrupt generated when the timer counter overflows ? wovi interrupt generation in interval timer mode ? choice of internal reset or nmi interrupt generation in watchdog timer mode 5(62 output in watchdog timer mode ? in watchdog timer mode, a low-level signal is output from the 5(62 pin when the counter overflows (when internal reset is selected) choice of 8 (wdt0) or 16 (wdt1) counter input clocks ? maximum wdt interval: system clock period 131072 256 ? subclock can be selected for the wdt1 input counter maximum interval when the subclock is selected: subclock period 256 256
394 14.1.2 block diagram figures 14.1 (a) and (b) show block diagrams of wdt0 and wdt1. overflow wovi0 (interrupt request signal) internal reset signal * 1 reso signal * 1 tcnt tcsr ?2 ?64 ?128 ?512 ?2048 ?8192 ?32768 ?131072 clock clock select internal clock source bus interface module bus internal bus wdt0 legend: tcsr: timer control/status register tcnt: timer counter internal nmi interrupt request signal * 2 interrupt control reset control notes: 1. reso pin output goes low when the internal reset signal is generated by overflow of tcnt in either wdt0 or wdt1. the reset of the wdt that overflowed first takes precedence over the internal reset signal. 2. the internal nmi interrupt request signal can be output independently by either wdt0 or wdt1. the interrupt controller does not distinguish between nmi interrupt requests from wdt0 and wdt1. figure 14.1 (a) block diagram of wdt0
395 overflow tcnt tcsr ?2 ?64 ?128 ?512 ?2048 ?8192 ?32768 ?131072 clock clock select interrupt control reset control internal clock source bus interface module bus internal bus wdt1 wovi1 (interrupt request signal) internal reset signal * 1 internal nmi (interrupt request signal) * 2 legend: tcsr: timer control/status register tcnt: timer counter sub /2 sub /4 sub /8 sub /16 sub /32 sub /64 sub /128 sub /256 reso signal * 1 notes: 1. reso pin output goes low when the internal reset signal is generated by overflow of tcnt in either wdt0 or wdt1. the reset of the wdt that overflowed first takes precedence over the internal reset signal. 2. the internal nmi interrupt request signal can be output independently by either wdt0 or wdt1. the interrupt controller does not distinguish between nmi interrupt requests from wdt0 and wdt1. figure 14.1 (b) block diagram of wdt1
396 14.1.3 pin configuration table 14.1 describes the wdt input pin. table 14.1 wdt pin name symbol i/o function reset output pin 5(62 output watchdog timer mode counter overflow signal output external subclock input pin excl input wdt1 prescaler counter input clock 14.1.4 register configuration the wdt has four registers, as summarized in table 14.2. these registers control clock selection, wdt mode switching, the reset signal, etc. table 14.2 wdt registers address * 1 channel name abbreviation r/w initial value write * 2 read 0 timer control/status register 0 tcsr0 r/(w) * 3 h'00 h'ffa8 h'ffa8 timer counter 0 tcnt0 r/w h'00 h'ffa8 h'ffa9 1 timer control/status register 1 tcsr1 r/(w) * 3 h'00 h'ffea h'ffea timer counter 1 tcnt1 r/w h'00 h'ffea h'ffeb common system control register syscr r/w h'09 h'ffc4 h'ffc4 notes: 1. lower 16 bits of the address. 2. for details of write operations, see section 14.2.4, notes on register access. 3. only 0 can be written in bit 7, to clear the flag.
397 14.2 register descriptions 14.2.1 timer counter (tcnt) 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write tcnt is an 8-bit readable/writable* up-counter. when the tme bit is set to 1 in tcsr, tcnt starts counting pulses generated from the internal clock source selected by bits cks2 to cks0 in tcsr. when the count overflows (changes from h'ff to h'00), the ovf flag in tcsr is set to 1. watchdog timer overflow signal ( 5(62 ) output, an internal reset, nmi interrupt, interval timer interrupt (wovi), etc., can be generated, depending on the mode selected by the wt/ ,7 bit and rst/ 10, bit. tcnt is initialized to h'00 by a reset, in hardware standby mode, or when the tme bit is cleared to 0. it is not initialized in software standby mode. note: * tcnt is write-protected by a password to prevent accidental overwriting. for details see section 14.2.4, notes on register access.
398 14.2.2 timer control/status register (tcsr) tcsr0 7 ovf 0 r/(w) * 6 wt/ it 0 r/w 5 tme 0 r/w 4 rsts 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write note: * only 0 can be written, to clear the flag. tcsr1 bit initial value read/write note: * only 0 can be written, to clear the flag. 7 ovf 0 r/(w) * 6 wt/ it 0 r/w 5 tme 0 r/w 4 pss 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w tcsr is an 8-bit readable/writable* register. its functions include selecting the clock source to be input to tcnt, and the timer mode. tcr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. note: * tcsr is write-protected by a password to prevent accidental overwriting. for details see section 14.2.4, notes on register access.
399 bit 7overflow flag (ovf): a status flag that indicates that tcnt has overflowed from h'ff to h'00. bit 7 ovf description 0 [clearing conditions] write 0 in the tme bit read tcsr when ovf = 1, then write 0 in ovf (initial value) 1 [setting condition] when tcnt overflows (changes from h'ff to h'00) (when internal reset request generation is selected in watchdog timer mode, ovf is cleared automatically by the internal reset.) bit 6timer mode select (wt/ ,7 ,7 ): selects whether the wdt is used as a watchdog timer or interval timer. if used as an interval timer, the wdt generates an interval timer interrupt request (wovi) when tcnt overflows. if used as a watchdog timer, the wdt generates a reset or nmi interrupt when tcnt overflows. when internal reset is selected in watchdog timer mode, a low- level signal is output from the 5(62 pin. bit 6 wt/ ,7 ,7 description 0 interval timer mode: sends the cpu an interval timer interrupt request (wovi) when tcnt overflows (initial value) 1 watchdog timer mode: generates a reset or nmi interrupt when tcnt overflows at the same time, a low-level signal is output from the 5(62 pin (when internal reset is selected) bit 5timer enable (tme): selects whether tcnt runs or is halted. bit 5 tme description 0 tcnt is initialized to h'00 and halted (initial value) 1 tcnt counts
400 tcsr0 bit 4reset select (rsts): reserved. this bit should not be set to 1. tcsr1 bit 4prescaler select (pss): selects the input clock source for tcnt in wdt1. for details, see the description of the cks2 to cks0 bits below. wdt1 tcsr bit 4 pss description 0 tcnt counts ?-based prescaler (psm) divided clock pulses (initial value) 1 tcnt counts ?sub-based prescaler (pss) divided clock pulses bit 3reset or nmi (rst/ 10, 10, ): specifies whether an internal reset or nmi interrupt is requested on tcnt overflow in watchdog timer mode. bit 3 rst/ 10, 10, description 0 an nmi interrupt is requested (initial value) 1 an internal reset is requested bits 2 to 0clock select 2 to 0 (cks2 to cks0): these bits select an internal clock source, obtained by dividing the system clock (?), or subclock (?sub) for input to tcnt. wdt0 input clock selection bit 2 bit 1 bit 0 description cks2 cks1 cks0 clock overflow period * (when ? = 20 mhz) 0 0 0 ?/2 (initial value) 25.6 s 1 ?/64 819.2 s 1 0 ?/128 1.6 ms 1 ?/512 6.6 ms 1 0 0 ?/2048 26.2 ms 1 ?/8192 104.9 ms 1 0 ?/32768 419.4 ms 1 ?/131072 1.68 s note: * the overflow period is the time from when tcnt starts counting up from h'00 until overflow occurs.
401 wdt1 input clock selection bit 4 bit 2 bit 1 bit 0 description pss cks2 cks1 cks0 clock overflow period * (when ? = 20 mhz and ? sub = 32.768 khz) 0 0 0 0 ?/2 (initial value) 25.6 s 1 ?/64 819.2 s 1 0 ?/128 1.6 ms 1 ?/512 6.6 ms 1 0 0 ?/2048 26.2 ms 1 ?/8192 104.9 ms 1 0 ?/32768 419.4 ms 1 ?/131072 1.68 s 1 0 0 0 ?sub/2 15.6 ms 1 ?sub/4 31.3 ms 1 0 ?sub/8 62.5 ms 1 ?sub/16 125 ms 1 0 0 ?sub/32 250 ms 1 ?sub/64 500 ms 1 0 ?sub/128 1 s 1 ?sub/256 2 s note: * the overflow period is the time from when tcnt starts counting up from h'00 until overflow occurs.
402 14.2.3 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write only bit 3 is described here. for details on functions not related to the watchdog timer, see sections 3.2.2 and 5.2.1, system control register (syscr), and the descriptions of the relevant modules. bit 3external reset (xrst): indicates the reset source. when the watchdog timer is used, a reset can be generated by watchdog timer overflow in addition to external reset input. xrst is a read-only bit. it is set to 1 by an external reset, and when the rst/ 10, bit is 1, is cleared to 0 by an internal reset due to watchdog timer overflow. bit 3 xrst description 0 reset is generated by watchdog timer overflow 1 reset is generated by external reset input (initial value)
403 14.2.4 notes on register access the watchdog timers tcnt and tcsr registers differ from other registers in being more difficult to write to. the procedures for writing to and reading these registers are given below. writing to tcnt and tcsr (example of wdt0): these registers must be written to by a word transfer instruction. they cannot be written to with byte transfer instructions. figure 14.2 shows the format of data written to tcnt and tcsr. tcnt and tcsr both have the same write address. for a write to tcnt, the upper byte of the written word must contain h'5a and the lower byte must contain the write data. for a write to tcsr, the upper byte of the written word must contain h'a5 and the lower byte must contain the write data. this transfers the write data from the lower byte to tcnt or tcsr. tcnt write tcsr write address: h'ffa8 address: h'ffa8 h'5a write data 15 8 7 0 h'a5 write data 15 8 7 0 figure 14.2 format of data written to tcnt and tcsr (example of wdt0) reading tcnt and tcsr (example of wdt0): these registers are read in the same way as other registers. the read addresses are h'ffa8 for tcsr, and h'ffa9 for tcnt. 14.3 operation 14.3.1 watchdog timer operation to use the wdt as a watchdog timer, set the wt/ ,7 and tme bits in tcsr to 1. software must prevent tcnt overflows by rewriting the tcnt value (normally by writing h'00) before overflow occurs. this ensures that tcnt does not overflow while the system is operating normally. if tcnt overflows without being rewritten because of a system crash or other error, an internal reset or nmi interrupt request is generated. when the rst/ 10, bit is set to 1, the chip is reset for 518 system clock periods (518 ?) by a counter overflow, and at the same time a low-level signal is output from the 5(62 pin for 132 states. this is illustrated in figure 14.3. the system can be reset using this 5(62 signal.
404 when the rst/ 10, bit cleared to 0, an nmi interrupt request is generated by a counter overflow. in this case, the 5(62 output signal remains high. an internal reset request from the watchdog timer and reset input from the 5(6 pin are handled via the same vector. the reset source can be identified from the value of the xrst bit in syscr. if a reset caused by an input signal from the 5(6 pin and a reset caused by wdt overflow occur simultaneously, the 5(6 pin reset has priority, and the xrst bit in syscr is set to 1. an nmi interrupt request from the watchdog timer and an interrupt request from the nmi pin are handled via the same vector. simultaneous handling of a watchdog timer nmi interrupt request and an nmi pin interrupt request must therefore be avoided. tcnt value h'00 time h'ff wt/ it = 1 tme = 1 h'00 written to tcnt wt/ it = 1 tme = 1 h'00 written to tcnt 518 system clock periods internal reset signal overflow reso and internal reset generated ovf = 1 * reso signal wt/ it : timer mode select bit tme: timer enable bit ovf: overflow flag note: * cleared to 0 by an internal reset when ovf is set to 1. xrst is cleared to 0. 132 system clock periods figure 14.3 operation in watchdog timer mode (rst/ 10, 10, = 1)
405 14.3.2 interval timer operation to use the wdt as an interval timer, clear the wt/ ,7 bit in tcsr to 0 and set the tme bit to 1. an interval timer interrupt (wovi) is generated each time tcnt overflows, provided that the wdt is operating as an interval timer, as shown in figure 14.4. this function can be used to generate interrupt requests at regular intervals. tcnt count h'00 time h'ff wt/ it = 0 tme = 1 wovi overflow overflow overflow overflow legend: wovi: interval timer interrupt request generation wovi wovi wovi figure 14.4 operation in interval timer mode
406 14.3.3 timing of setting of overflow flag (ovf) the ovf flag is set to 1 if tcnt overflows during interval timer operation. at the same time, an interval timer interrupt (wovi) is requested. this timing is shown in figure 14.5. if nmi request generation is selected in watchdog timer mode, when tcnt overflows the ovf bit in tcsr is set to 1 and at the same time an nmi interrupt is requested. tcnt h'ff h'00 overflow signal (internal signal) ovf figure 14.5 timing of ovf setting
407 14.3.4 5(62 5(62 signal output timing when tcnt overflows in watchdog timer mode, the ovf bit is set to 1 in tcsr. if the rst/ 10, bit is 1 at this time, an internal reset signal is generated for the entire chip, and at the same time a low-level signal is output from the 5(62 pin. the timing is shown in figure 14-6. tcnt h'ff h'00 132 states 518 states overflow signal (internal signal) ovf reso signal internal reset signal figure 14.6 5(62 5(62 signal output timing 14.4 interrupts during interval timer mode operation, an overflow generates an interval timer interrupt (wovi). the interval timer interrupt is requested whenever the ovf flag is set to 1 in tcsr. ovf must be cleared to 0 in the interrupt handling routine. when nmi interrupt request generation is selected in watchdog timer mode, an overflow generates an nmi interrupt request.
408 14.5 usage notes 14.5.1 contention between timer counter (tcnt) write and increment if a timer counter clock pulse is generated during the t 2 state of a tcnt write cycle, the write takes priority and the timer counter is not incremented. figure 14.7 shows this operation. address internal write signal tcnt input clock tcnt nm t 1 t 2 tcnt write cycle counter write data figure 14.7 contention between tcnt write and increment 14.5.2 changing value of cks2 to cks0 if bits cks2 to cks0 in tcsr are written to while the wdt is operating, errors could occur in the incrementation. software must stop the watchdog timer (by clearing the tme bit to 0) before changing the value of bits cks2 to cks0. 14.5.3 switching between watchdog timer mode and interval timer mode if the mode is switched from watchdog timer to interval timer, or vice versa, while the wdt is operating, errors could occur in the incrementation. software must stop the watchdog timer (by clearing the tme bit to 0) before switching the mode.
409 14.5.4 system reset by 5(62 5(62 signal if the 5(62 output signal is input to the chips 5(6 pin, the chip will not be initialized correctly. ensure that the 5(62 signal is not logically input to the chips 5(6 pin. when resetting the entire system with the 5(62 signal, use a circuit such as that shown in figure 14.8. reset input reset signal to entire system chip res reso figure 14.8 sample circuit for system reset by 5(62 5(62 signal 14.5.5 counter value in transitions between high-speed mode, subactive mode, and watch mode if the mode is switched between high-speed mode and subactive mode or between high-speed mode and watch mode when wdt1 is used as a realtime clock counter, an error will occur in the counter value when the internal clock is switched. when the mode is switched from high-speed mode to subactive mode or watch mode, the increment timing is delayed by approximately 2 or 3 clock cycles when the wdt1 control clock is switched from the main clock to the subclock. also, since the main clock oscillator is halted during subclock operation, when the mode is switched from watch mode or subactive mode to high-speed mode, the clock is not supplied until internal oscillation stabilizes. as a result, after oscillation is started, counter incrementing is halted during the oscillation stabilization time set by bits sts2 to sts0 in sbycr, and there is a corresponding discrepancy in the counter value. caution is therefore required when using wdt1 as the realtime clock counter. no error occurs in the counter value while wdt1 is operating in the same mode.
410
411 section 15 serial communication interface (sci, irda) 15.1 overview the h8s/2148 series and h8s/2144 series are equipped with a 3-channel serial communication interface (sci). the sci can handle both asynchronous and clocked synchronous serial communication. a function is also provided for serial communication between processors (multiprocessor communication function). one of the three sci channels can transmit and receive irda communication waveforms based on irda specification version 1.0. 15.1.1 features sci features are listed below. choice of asynchronous or synchronous serial communication mode asynchronous mode ? serial data communication is executed using an asynchronous system in which synchronization is achieved character by character serial data communication can be carried out with standard asynchronous communication chips such as a universal asynchronous receiver/transmitter (uart) or asynchronous communication interface adapter (acia) ? a multiprocessor communication function is provided that enables serial data communication with a number of processors ? choice of 12 serial data transfer formats data length: 7 or 8 bits stop bit length: 1 or 2 bits parity: even, odd, or none multiprocessor bit: 1 or 0 ? receive error detection: parity, overrun, and framing errors ? break detection: break can be detected by reading the rxd pin level directly in case of a framing error synchronous mode ? serial data communication is synchronized with a clock serial data communication can be carried out with other chips that have a synchronous communication function ? one serial data transfer format data length: 8 bits ? receive error detection: overrun errors detected
412 full-duplex communication capability ? the transmitter and receiver are mutually independent, enabling transmission and reception to be executed simultaneously ? double-buffering is used in both the transmitter and the receiver, enabling continuous transmission and continuous reception of serial data lsb-first or msb-first transfer can be selected ? this selection can be made regardless of the communication mode (with the exception of 7-bit data transfer in asynchronous mode)* note: * lsb-first transfer is used in the examples in this section. built-in baud rate generator allows any bit rate to be selected choice of serial clock source: internal clock from baud rate generator or external clock from sck pin four interrupt sources ? four interrupt sources (transmit-data-empty, transmit-end, receive-data-full, and receive error) that can issue requests independently ? the transmit-data-empty interrupt and receive-data-full interrupt can activate the data transfer controller (dtc) to execute data transfer
413 15.1.2 block diagram figure 15.1 shows a block diagram of the sci. bus interface tdr rsr rdr module data bus tsr ssr scmr scr smr transmission/ reception control brr baud rate generator internal data bus rxd txd sck parity generation parity check clock external clock ?4 ?16 ?64 txi tei rxi eri legend: rsr: receive shift register rdr: receive data register tsr: transmit shift register tdr: transmit data register smr: serial mode register scr: serial control register ssr: serial status register scmr: serial interface mode register brr: bit rate register figure 15.1 block diagram of sci
414 15.1.3 pin configuration table 15.1 shows the serial pins used by the sci. table 15.1 sci pins channel pin name symbol * i/o function 0 serial clock pin 0 sck0 i/o sci0 clock input/output receive data pin 0 rxd0 input sci0 receive data input transmit data pin 0 txd0 output sci0 transmit data output 1 serial clock pin 1 sck1 i/o sci1 clock input/output receive data pin 1 rxd1 input sci1 receive data input transmit data pin 1 txd1 output sci1 transmit data output 2 serial clock pin 2 sck2 i/o sci2 clock input/output receive data pin 2 rxd2/irrxd input sci2 receive data input (normal/irda) transmit data pin 2 txd2/irtxd output sci2 transmit data output (normal/irda) note: * the abbreviations sck, rxd, and txd are used in the text, omitting the channel number.
415 15.1.4 register configuration the sci has the internal registers shown in table 15.2. these registers are used to specify asynchronous mode or synchronous mode, the data format, and the bit rate, and to control the transmitter/receiver. table 15.2 sci registers channel name abbreviation r/w initial value address * 1 0 serial mode register 0 smr0 r/w h'00 h'ffd8 * 3 bit rate register 0 brr0 r/w h'ff h'ffd9 * 3 serial control register 0 scr0 r/w h'00 h'ffda transmit data register 0 tdr0 r/w h'ff h'ffdb serial status register 0 ssr0 r/(w) * 2 h'84 h'ffdc receive data register 0 rdr0 r h'00 h'ffdd serial interface mode register 0 scmr0 r/w h'f2 h'ffde * 3 1 serial mode register 1 smr1 r/w h'00 h'ff88 * 3 bit rate register 1 brr1 r/w h'ff h'ff89 * 3 serial control register 1 scr1 r/w h'00 h'ff8a transmit data register 1 tdr1 r/w h'ff h'ff8b serial status register 1 ssr1 r/(w) * 2 h'84 h'ff8c receive data register 1 rdr1 r h'00 h'ff8d serial interface mode register 1 scmr1 r/w h'f2 h'ff8e * 3 2 serial mode register 2 smr2 r/w h'00 h'ffa0 * 3 bit rate register 2 brr2 r/w h'ff h'ffa1 * 3 serial control register 2 scr2 r/w h'00 h'ffa2 transmit data register 2 tdr2 r/w h'ff h'ffa3 serial status register 2 ssr2 r/(w) * 2 h'84 h'ffa4 receive data register 2 rdr2 r h'00 h'ffa5 serial interface mode register 2 scmr2 r/w h'f2 h'ffa6 * 3 keyboard comparator control register kbcomp r/w h'00 h'fee4 common module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. only 0 can be written, to clear flags. 3. some serial communication interface registers are assigned to the same addresses as other registers. in this case, register selection is performed by the iice bit in the serial timer control register (stcr).
416 15.2 register descriptions 15.2.1 receive shift register (rsr) 7 6 5 4 3 0 2 1 bit read/write rsr is a register used to receive serial data. the sci sets serial data input from the rxd pin in rsr in the order received, starting with the lsb (bit 0), and converts it to parallel data. when one byte of data has been received, it is transferred to rdr automatically. rsr cannot be directly read or written to by the cpu. 15.2.2 receive data register (rdr) 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r bit initial value read/write rdr is a register that stores received serial data. when the sci has received one byte of serial data, it transfers the received serial data from rsr to rdr where it is stored, and completes the receive operation. after this, rsr is receive- enabled. since rsr and rdr function as a double buffer in this way, continuous receive operations can be performed. rdr is a read-only register, and cannot be written to by the cpu. rdr is initialized to h'00 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode.
417 15.2.3 transmit shift register (tsr) 7 6 5 4 3 0 2 1 bit read/write tsr is a register used to transmit serial data. to perform serial data transmission, the sci first transfers transmit data from tdr to tsr, then sends the data to the txd pin starting with the lsb (bit 0). when transmission of one byte is completed, the next transmit data is transferred from tdr to tsr, and transmission started, automatically. however, data transfer from tdr to tsr is not performed if the tdre bit in ssr is set to 1. tsr cannot be directly read or written to by the cpu. 15.2.4 transmit data register (tdr) 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write tdr is an 8-bit register that stores data for serial transmission. when the sci detects that tsr is empty, it transfers the transmit data written in tdr to tsr and starts serial transmission. continuous serial transmission can be carried out by writing the next transmit data to tdr during serial transmission of the data in tsr. tdr can be read or written to by the cpu at all times. tdr is initialized to h'ff by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode.
418 15.2.5 serial mode register (smr) 7 c/ a 0 r/w 6 chr 0 r/w 5 pe 0 r/w 4 o/ e 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w bit initial value read/write smr is an 8-bit register used to set the scis serial transfer format and select the baud rate generator clock source. smr can be read or written to by the cpu at all times. smr is initialized to h'00 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7communication mode (c/ $ $ ): selects asynchronous mode or synchronous mode as the sci operating mode. bit 7 c/ $ $ description 0 asynchronous mode (initial value) 1 synchronous mode bit 6character length (chr): selects 7 or 8 bits as the data length in asynchronous mode. in synchronous mode, a fixed data length of 8 bits is used regardless of the chr setting. bit 6 chr description 0 8-bit data (initial value) 1 7-bit data * note: * when 7-bit data is selected, the msb (bit 7) of tdr is not transmitted, and lsb-first/msb- first selection is not available.
419 bit 5parity enable (pe): in asynchronous mode, selects whether or not parity bit addition is performed in transmission, and parity bit checking in reception. in synchronous mode, or when a multiprocessor format is used, parity bit addition and checking is not performed, regardless of the pe bit setting. bit 5 pe description 0 parity bit addition and checking disabled (initial value) 1 parity bit addition and checking enabled * note: * when the pe bit is set to 1, the parity (even or odd) specified by the o/ ( bit is added to transmit data before transmission. in reception, the parity bit is checked for the parity (even or odd) specified by the o/ ( bit. bit 4parity mode (o/ ( ( ): selects either even or odd parity for use in parity addition and checking. the o/ ( bit setting is only valid when the pe bit is set to 1, enabling parity bit addition and checking, in asynchronous mode. the o/ ( bit setting is invalid in synchronous mode, when parity bit addition and checking is disabled in asynchronous mode, and when a multiprocessor format is used. bit 4 o/ ( ( description 0 even parity * 1 (initial value) 1 odd parity * 2 notes: 1. when even parity is set, parity bit addition is performed in transmission so that the total number of 1 bits in the transmit character plus the parity bit is even. in reception, a check is performed to see if the total number of 1 bits in the receive character plus the parity bit is even. 2. when odd parity is set, parity bit addition is performed in transmission so that the total number of 1 bits in the transmit character plus the parity bit is odd. in reception, a check is performed to see if the total number of 1 bits in the receive character plus the parity bit is odd.
420 bit 3stop bit length (stop): selects 1 or 2 bits as the stop bit length in asynchronous mode. the stop bit setting is only valid in asynchronous mode. if synchronous mode is set the stop bit setting is invalid since stop bits are not added. bit 3 stop description 0 1 stop bit * 1 (initial value) 1 2 stop bits * 2 notes: 1. in transmission, a single 1 bit (stop bit) is added to the end of a transmit character before it is sent. 2. in transmission, two 1 bits (stop bits) are added to the end of a transmit character before it is sent. in reception, only the first stop bit is checked, regardless of the stop bit setting. if the second stop bit is 1, it is treated as a stop bit; if it is 0, it is treated as the start bit of the next transmit character. bit 2multiprocessor mode (mp): selects multiprocessor format. when multiprocessor format is selected, the pe bit and o/ ( bit parity settings are invalid. the mp bit setting is only valid in asynchronous mode; it is invalid in synchronous mode. for details of the multiprocessor communication function, see section 15.3.3, multiprocessor communication function. bit 2 mp description 0 multiprocessor function disabled (initial value) 1 multiprocessor format selected
421 bits 1 and 0clock select 1 and 0 (cks1, cks0): these bits select the clock source for the baud rate generator. the clock source can be selected from ?, ?/4, ?/16, and ?/64, according to the setting of bits cks1 and cks0. for the relation between the clock source, the bit rate register setting, and the baud rate, see section 15.2.8, bit rate register. bit 1 bit 0 cks1 cks0 description 0 0 ? clock (initial value) 1 ?/4 clock 1 0 ?/16 clock 1 ?/64 clock
422 15.2.6 serial control register (scr) 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w bit initial value read/write scr is a register that performs enabling or disabling of sci transfer operations, serial clock output in asynchronous mode, and interrupt requests, and selection of the serial clock source. scr can be read or written to by the cpu at all times. scr is initialized to h'00 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7transmit interrupt enable (tie): enables or disables transmit-data-empty interrupt (txi) request generation when serial transmit data is transferred from tdr to tsr and the tdre flag in ssr is set to 1. bit 7 tie description 0 transmit-data-empty interrupt (txi) request disabled * (initial value) 1 transmit-data-empty interrupt (txi) request enabled note: * txi interrupt request cancellation can be performed by reading 1 from the tdre flag, then clearing it to 0, or clearing the tie bit to 0. bit 6receive interrupt enable (rie): enables or disables receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request generation when serial receive data is transferred from rsr to rdr and the rdrf flag in ssr is set to 1. bit 6 rie description 0 receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request disabled * (initial value) 1 receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request enabled note: * rxi and eri interrupt request cancellation can be performed by reading 1 from the rdrf, fer, per, or orer flag, then clearing the flag to 0, or clearing the rie bit to 0.
423 bit 5transmit enable (te): enables or disables the start of serial transmission by the sci. bit 5 te description 0 transmission disabled * 1 (initial value) 1 transmission enabled * 2 notes: 1. the tdre flag in ssr is fixed at 1. 2. in this state, serial transmission is started when transmit data is written to tdr and the tdre flag in ssr is cleared to 0. smr setting must be performed to decide the transmission format before setting the te bit to 1. bit 4receive enable (re): enables or disables the start of serial reception by the sci. bit 4 re description 0 reception disabled * 1 (initial value) 1 reception enabled * 2 notes: 1. clearing the re bit to 0 does not affect the rdrf, fer, per, and orer flags, which retain their states. 2. serial reception is started in this state when a start bit is detected in asynchronous mode or serial clock input is detected in synchronous mode. smr setting must be performed to decide the reception format before setting the re bit to 1.
424 bit 3multiprocessor interrupt enable (mpie): enables or disables multiprocessor interrupts. the mpie bit setting is only valid in asynchronous mode when receiving with the mp bit in smr set to 1. the mpie bit setting is invalid in synchronous mode or when the mp bit is cleared to 0. bit 3 mpie description 0 multiprocessor interrupts disabled (normal reception performed) (initial value) [clearing conditions] when the mpie bit is cleared to 0 when data with mpb = 1 is received 1 multiprocessor interrupts enabled * receive interrupt (rxi) requests, receive-error interrupt (eri) requests, and setting of the rdrf, fer, and orer flags in ssr are disabled until data with the multiprocessor bit set to 1 is received. note: * when receive data including mpb = 0 is received, receive data transfer from rsr to rdr, receive error detection, and setting of the rdrf, fer, and orer flags in ssr , is not performed. when receive data with mpb = 1 is received, the mpb bit in ssr is set to 1, the mpie bit is cleared to 0 automatically, and generation of rxi and eri interrupts (when the tie and rie bits in scr are set to 1) and fer and orer flag setting is enabled. bit 2transmit end interrupt enable (teie): enables or disables transmit-end interrupt (tei) request generation if there is no valid transmit data in tdr when the msb is transmitted. bit 2 teie description 0 transmit-end interrupt (tei) request disabled * (initial value) 1 transmit-end interrupt (tei) request enabled * note: * tei cancellation can be performed by reading 1 from the tdre flag in ssr, then clearing it to 0 and clearing the tend flag to 0, or clearing the teie bit to 0.
425 bits 1 and 0clock enable 1 and 0 (cke1, cke0): these bits are used to select the sci clock source and enable or disable clock output from the sck pin. the combination of the cke1 and cke0 bits determines whether the sck pin functions as an i/o port, the serial clock output pin, or the serial clock input pin. the setting of the cke0 bit, however, is only valid for internal clock operation (cke1 = 0) in asynchronous mode. the cke0 bit setting is invalid in synchronous mode, and in the case of external clock operation (cke1 = 1). the setting of bits cke1 and cke0 must be carried out before the scis operating mode is determined using smr. for details of clock source selection, see table 15.9 in section 15.3, operation. bit 1 bit 0 cke1 cke0 description 0 0 asynchronous mode internal clock/sck pin functions as i/o port * 1 synchronous mode internal clock/sck pin functions as serial clock output * 1 1 asynchronous mode internal clock/sck pin functions as clock output * 2 synchronous mode internal clock/sck pin functions as serial clock output 1 0 asynchronous mode external clock/sck pin functions as clock input * 3 synchronous mode external clock/sck pin functions as serial clock input 1 asynchronous mode external clock/sck pin functions as clock input * 3 synchronous mode external clock/sck pin functions as serial clock input notes: 1. initial value 2. outputs a clock of the same frequency as the bit rate. 3. inputs a clock with a frequency 16 times the bit rate.
426 15.2.7 serial status register (ssr) 7 tdre 1 r/(w) * 6 rdrf 0 r/(w) * 5 orer 0 r/(w) * 4 fer 0 r/(w) * 3 per 0 r/(w) * 0 mpbt 0 r/w 2 tend 1 r 1 mpb 0 r bit initial value read/write note: only 0 can be written, to clear the flag. ssr is an 8-bit register containing status flags that indicate the operating status of the sci, and multiprocessor bits. ssr can be read or written to by the cpu at all times. however, 1 cannot be written to flags tdre, rdrf, orer, per, and fer. also note that in order to clear these flags they must be read as 1 beforehand. the tend flag and mpb flag are read-only flags and cannot be modified. ssr is initialized to h'84 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7transmit data register empty (tdre): indicates that data has been transferred from tdr to tsr and the next serial data can be written to tdr. bit 7 tdre description 0 [clearing conditions] when 0 is written in tdre after reading tdre = 1 when the dtc is activated by a txi interrupt and writes data to tdr 1 [setting conditions] (initial value) when the te bit in scr is 0 when data is transferred from tdr to tsr and data can be written to tdr
427 bit 6receive data register full (rdrf): indicates that the received data is stored in rdr. bit 6 rdrf description 0 [clearing conditions] (initial value) when 0 is written in rdrf after reading rdrf = 1 when the dtc is activated by an rxi interrupt and reads data from rdr 1 [setting condition] when serial reception ends normally and receive data is transferred from rsr to rdr note: rdr and the rdrf flag are not affected and retain their previous values when an error is detected during reception or when the re bit in scr is cleared to 0. if reception of the next data is completed while the rdrf flag is still set to 1, an overrun error will occur and the receive data will be lost. bit 5overrun error (orer): indicates that an overrun error occurred during reception, causing abnormal termination. bit 5 orer description 0 [clearing condition] (initial value) * 1 when 0 is written in orer after reading orer = 1 1 [setting condition] when the next serial reception is completed while rdrf = 1 * 2 notes: 1. the orer flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 2. the receive data prior to the overrun error is retained in rdr, and the data received subsequently is lost. also, subsequent serial reception cannot be continued while the orer flag is set to 1. in synchronous mode, serial transmission cannot be continued, either.
428 bit 4framing error (fer): indicates that a framing error occurred during reception in asynchronous mode, causing abnormal termination. bit 4 fer description 0 [clearing condition] (initial value) * 1 when 0 is written in fer after reading fer = 1 1 [setting condition] when the sci checks the stop bit at the end of the receive data when reception ends, and the stop bit is 0 * 2 notes: 1. the fer flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 2. in 2-stop-bit mode, only the first stop bit is checked for a value of 0; the second stop bit is not checked. if a framing error occurs, the receive data is transferred to rdr but the rdrf flag is not set. also, subsequent serial reception cannot be continued while the fer flag is set to 1. in synchronous mode, serial transmission cannot be continued, either. bit 3parity error (per): indicates that a parity error occurred during reception using parity addition in asynchronous mode, causing abnormal termination. bit 3 per description 0 [clearing condition] (initial value) * 1 when 0 is written in per after reading per = 1 1 [setting condition] when, in reception, the number of 1 bits in the receive data plus the parity bit does not match the parity setting (even or odd) specified by the o/ ( bit in smr * 2 notes: 1. the per flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 2. if a parity error occurs, the receive data is transferred to rdr but the rdrf flag is not set. also, subsequent serial reception cannot be continued while the per flag is set to 1. in synchronous mode, serial transmission cannot be continued, either.
429 bit 2transmit end (tend): indicates that there is no valid data in tdr when the last bit of the transmit character is sent, and transmission has been ended. the tend flag is read-only and cannot be modified. bit 2 tend description 0 [clearing conditions] when 0 is written in tdre after reading tdre = 1 when the dtc is activated by a txi interrupt and writes data to tdr 1 [setting conditions] (initial value) when the te bit in scr is 0 when tdre = 1 at transmission of the last bit of a 1-byte serial transmit character bit 1multiprocessor bit (mpb): when reception is performed using a multiprocessor format in asynchronous mode, mpb stores the multiprocessor bit in the receive data. mpb is a read-only bit, and cannot be modified. bit 1 mpb description 0 [clearing condition] (initial value) * when data with a 0 multiprocessor bit is received 1 [setting condition] when data with a 1 multiprocessor bit is received note: * retains its previous state when the re bit in scr is cleared to 0 with multiprocessor format. bit 0multiprocessor bit transfer (mpbt): when transmission is performed using a multiprocessor format in asynchronous mode, mpbt stores the multiprocessor bit to be added to the transmit data. the mpbt bit setting is invalid when a multiprocessor format is not used, when not transmitting, and in synchronous mode. bit 0 mpbt description 0 data with a 0 multiprocessor bit is transmitted (initial value) 1 data with a 1 multiprocessor bit is transmitted
430 15.2.8 bit rate register (brr) 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write brr is an 8-bit register that sets the serial transfer bit rate in accordance with the baud rate generator operating clock selected by bits cks1 and cks0 in smr. brr can be read or written to by the cpu at all times. brr is initialized to h'ff by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. as baud rate generator control is performed independently for each channel, different values can be set for each channel. table 15.3 shows sample brr settings in asynchronous mode, and table 15.4 shows sample brr settings in synchronous mode.
431 table 15.3 brr settings for various bit rates (asynchronous mode) operating frequency ? (mhz) ? = 2 mhz ? = 2.097152 mhz ? = 2.4576 mhz ? = 3 mhz bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 1 141 0.03 1 148 C0.04 1 174 C0.26 1 212 0.03 150 1 103 0.16 1 108 0.21 1 127 0.00 1 155 0.16 300 0 207 0.16 0 217 0.21 0 255 0.00 1 77 0.16 600 0 103 0.16 0 108 0.21 0 127 0.00 0 155 0.16 1200 0 51 0.16 0 54 C0.70 0 63 0.00 0 77 0.16 2400 0 25 0.16 0 26 1.14 0 31 0.00 0 38 0.16 4800 0 12 0.16 0 13 C2.48 0 15 0.00 0 19 C2.34 9600 0 6 C2.48 0 7 0.00 0 9 C2.34 19200 0 3 0.00 0 4 C2.34 31250 0 1 0.00 0 2 0.00 38400 0 1 0.00 operating frequency ? (mhz) ? = 3.6864 mhz ? = 4 mhz ? = 4.9152 mhz ? = 5 mhz bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 64 0.70 2 70 0.03 2 86 0.31 2 88 C0.25 150 1 191 0.00 1 207 0.16 1 255 0.00 2 64 0.16 300 1 95 0.00 1 103 0.16 1 127 0.00 1 129 0.16 600 0 191 0.00 0 207 0.16 0 255 0.00 1 64 0.16 1200 0 95 0.00 0 103 0.16 0 127 0.00 0 129 0.16 2400 0 47 0.00 0 51 0.16 0 63 0.00 0 64 0.16 4800 0 23 0.00 0 25 0.16 0 31 0.00 0 32 C1.36 9600 0 11 0.00 0 12 0.16 0 15 0.00 0 15 1.73 19200 0 5 0.00 0 7 0.00 0 7 1.73 31250 0 3 0.00 0 4 C1.70 0 4 0.00 38400 0 2 0.00 0 3 0.00 0 3 1.73
432 table 15.3 brr settings for various bit rates (asynchronous mode) (cont) operating frequency ? (mhz) ? = 6 mhz ? = 6.144 mhz ? = 7.3728 mhz ? = 8 mhz bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 106 C0.44 2 108 0.08 2 130 C0.07 2 141 0.03 150 2 77 0.16 2 79 0.00 2 95 0.00 2 103 0.16 300 1 155 0.16 1 159 0.00 1 191 0.00 1 207 0.16 600 1 77 0.16 1 79 0.00 1 95 0.00 1 103 0.16 1200 0 155 0.16 0 159 0.00 0 191 0.00 0 207 0.16 2400 0 77 0.16 0 79 0.00 0 95 0.00 0 103 0.16 4800 0 38 0.16 0 39 0.00 0 47 0.00 0 51 0.16 9600 0 19 C2.34 0 19 0.00 0 23 0.00 0 25 0.16 19200 0 9 C2.34 0 9 0.00 0 11 0.00 0 12 0.16 31250 0 5 0.00 0 5 2.40 0 7 0.00 38400 0 4 C2.34 0 4 0.00 0 5 0.00 operating frequency ? (mhz) ? = 9.8304 mhz ? = 10 mhz ? = 12 mhz ? = 12.288 mhz bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 174 C0.26 2 177 C0.25 2 212 0.03 2 217 0.08 150 2 127 0.00 2 129 0.16 2 155 0.16 2 159 0.00 300 1 255 0.00 2 64 0.16 2 77 0.16 2 79 0.00 600 1 127 0.00 1 129 0.16 1 155 0.16 1 159 0.00 1200 0 255 0.00 1 64 0.16 1 77 0.16 1 79 0.00 2400 0 127 0.00 0 129 0.16 0 155 0.16 0 159 0.00 4800 0 63 0.00 0 64 0.16 0 77 0.16 0 79 0.00 9600 0 31 0.00 0 32 C1.36 0 38 0.16 0 39 0.00 19200 0 15 0.00 0 15 1.73 0 19 C2.34 0 19 0.00 31250 0 9 C1.70 0 9 0.00 0 11 0.00 0 11 2.40 38400 0 7 0.00 0 7 1.73 0 9 C2.34 0 9 0.00
433 table 15.3 brr settings for various bit rates (asynchronous mode) (cont) operating frequency ? (mhz) ? = 14 mhz ? = 14.7456 mhz ? = 16 mhz ? = 17.2032 mhz bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 248 C0.17 3 64 0.70 3 70 0.03 3 75 0.48 150 2 181 0.16 2 191 0.00 2 207 0.16 2 223 0.00 300 2 90 0.16 2 95 0.00 2 103 0.16 2 111 0.00 600 1 181 0.16 1 191 0.00 1 207 0.16 1 223 0.00 1200 1 90 0.16 1 95 0.00 1 103 0.16 1 111 0.00 2400 0 181 0.16 0 191 0.00 0 207 0.16 0 223 0.00 4800 0 90 0.16 0 95 0.00 0 103 0.16 0 111 0.00 9600 0 45 C0.93 0 47 0.00 0 51 0.16 0 55 0.00 19200 0 22 C0.93 0 23 0.00 0 25 0.16 0 27 0.00 31250 0 13 0.00 0 14 C1.70 0 15 0.00 0 16 1.20 38400 0 11 0.00 0 12 0.16 0 13 0.00 operating frequency ? (mhz) ? = 18 mhz ? = 19.6608 mhz ? = 20 mhz bit rate (bits/s) n n error (%) n n error (%) n n error (%) 110 3 79 C0.12 3 86 0.31 3 88 C0.25 150 2 233 0.16 2 255 0.00 3 64 0.16 300 2 116 0.16 2 127 0.00 2 129 0.16 600 1 233 0.16 1 255 0.00 2 64 0.16 1200 1 116 0.16 1 127 0.00 1 129 0.16 2400 0 233 0.16 0 255 0.00 1 64 0.16 4800 0 116 0.16 0 127 0.00 0 129 0.16 9600 0 58 C0.69 0 63 0.00 0 64 0.16 19200 0 28 1.02 0 31 0.00 0 32 C1.36 31250 0 17 0.00 0 19 C1.70 0 19 0.00 38400 0 14 C2.34 0 15 0.00 0 15 1.73
434 table 15.4 brr settings for various bit rates (synchronous mode) operating frequency ? (mhz) bit rate ? = 2 mhz ? = 4 mhz ? = 8 mhz ? = 10 mhz ? = 16 mhz ? = 20 mhz (bits/s) n n n n n n n n n n n n 110 3 70 250 2 124 2 249 3 124 3 249 500 1 249 2 124 2 249 3 124 1 k 1 124 1 249 2 124 2 249 2.5 k 0 199 1 99 1 199 1 249 2 99 2 124 5 k 0 99 0 199 1 99 1 124 1 199 1 249 10 k 0 49 0 99 0 199 0 249 1 99 1 124 25 k 0 19 0 39 0 79 0 99 0 159 0 199 50 k 0 9 0 19 0 39 0 49 0 79 0 99 100 k 0 4 0 9 0 19 0 24 0 39 0 49 250 k 0 1 0 3 0 7 0 9 0 15 0 19 500 k 0 0 * 0103040709 1 m 0 0 * 01 0304 2.5 m 0 0 * 01 5 m 00 * note: as far as possible, the setting should be made so that the error is no more than 1%. legend: blank: cannot be set. : can be set, but there will be a degree of error. * : continuous transfer is not possible.
435 the brr setting is found from the following equations. asynchronous mode: n = 10 6 ?1 64 2 2n? b f synchronous mode: n = 10 6 ?1 8 2 2n? b f where b: bit rate (bits/s) n: brr setting for baud rate generator (0 n 255) ?: operating frequency (mhz) n: baud rate generator input clock (n = 0 to 3) (see the table below for the relation between n and the clock.) smr setting n clock cks1 cks0 0? 0 0 1 ?/4 0 1 2 ?/16 1 0 3 ?/64 1 1 the bit rate error in asynchronous mode is found from the following equation: error (%) = ?1 100 (n + 1) b 64 2 2n? f 10 6 ? ?
436 table 15.5 shows the maximum bit rate for each frequency in asynchronous mode. tables 15.6 and 15.7 show the maximum bit rates with external clock input. table 15.5 maximum bit rate for each frequency (asynchronous mode) ? (mhz) maximum bit rate (bits/s) n n 2 62500 0 0 2.097152 65536 0 0 2.4576 76800 0 0 3 93750 0 0 3.6864 115200 0 0 4 125000 0 0 4.9152 153600 0 0 5 156250 0 0 6 187500 0 0 6.144 192000 0 0 7.3728 230400 0 0 8 250000 0 0 9.8304 307200 0 0 10 312500 0 0 12 375000 0 0 12.288 384000 0 0 14 437500 0 0 14.7456 460800 0 0 16 500000 0 0 17.2032 537600 0 0 18 562500 0 0 19.6608 614400 0 0 20 625000 0 0
437 table 15.6 maximum bit rate with external clock input (asynchronous mode) ? (mhz) external input clock (mhz) maximum bit rate (bits/s) 2 0.5000 31250 2.097152 0.5243 32768 2.4576 0.6144 38400 3 0.7500 46875 3.6864 0.9216 57600 4 1.0000 62500 4.9152 1.2288 76800 5 1.2500 78125 6 1.5000 93750 6.144 1.5360 96000 7.3728 1.8432 115200 8 2.0000 125000 9.8304 2.4576 153600 10 2.5000 156250 12 3.0000 187500 12.288 3.0720 192000 14 3.5000 218750 14.7456 3.6864 230400 16 4.0000 250000 17.2032 4.3008 268800 18 4.5000 281250 19.6608 4.9152 307200 20 5.0000 312500 table 15.7 maximum bit rate with external clock input (synchronous mode) ? (mhz) external input clock (mhz) maximum bit rate (bits/s) 2 0.3333 333333.3 4 0.6667 666666.7 6 1.0000 1000000.0 8 1.3333 1333333.3 10 1.6667 1666666.7 12 2.0000 2000000.0 14 2.3333 2333333.3 16 2.6667 2666666.7 18 3.0000 3000000.0 20 3.3333 3333333.3
438 15.2.9 serial interface mode register (scmr) 7 ? 1 6 ? 1 5 ? 1 4 ? 1 3 sdir 0 r/w 0 smif 0 r/w 2 sinv 0 r/w 1 ? 1 bit initial value read/write scmr is an 8-bit readable/writable register used to select sci functions. scmr is initialized to h'f2 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bits 7 to 4reserved: these bits cannot be modified and are always read as 1. bit 3data transfer direction (sdir): selects the serial/parallel conversion format. bit 3 sdir description 0 tdr contents are transmitted lsb-first (initial value) receive data is stored in rdr lsb-first 1 tdr contents are transmitted msb-first receive data is stored in rdr msb-first
439 bit 2data invert (sinv): specifies inversion of the data logic level. the sinv bit does not affect the logic level of the parity bit(s): parity bit inversion requires inversion of the o/ ( bit in smr. bit 2 sinv description 0 tdr contents are transmitted without modification (initial value) receive data is stored in rdr without modification 1 tdr contents are inverted before being transmitted receive data is stored in rdr in inverted form bit 1reserved: this bit cannot be modified and is always read as 1. bit 0serial communication interface mode select (smif): reserved bit. 1 should not be written in this bit. bit 0 smif description 0 normal sci mode (initial value) 1 reserved mode
440 15.2.10 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when bit mstp7, mstp6, or mstp5 is set to 1, sci0, sci1, or sci2 operation, respectively, stops at the end of the bus cycle and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7module stop (mstp7): specifies the sci0 module stop mode. mstpcrl bit 7 mstp7 description 0 sci0 module stop mode is cleared 1 sci0 module stop mode is set (initial value)
441 bit 6module stop (mstp6): specifies the sci1 module stop mode. mstpcrl bit 6 mstp6 description 0 sci1 module stop mode is cleared 1 sci1 module stop mode is set (initial value) bit 5module stop (mstp5): specifies the sci2 module stop mode. mstpcrl bit 5 mstp5 description 0 sci2 module stop mode is cleared 1 sci2 module stop mode is set (initial value)
442 15.2.11 keyboard comparator control register (kbcomp) 7 ire 0 r/w 6 ircks2 0 r/w 5 ircks1 0 r/w 4 ircks0 0 r/w 3 kbade 0 r/w 0 kbch0 0 r/w 2 kbch2 0 r/w 1 kbch1 0 r/w bit initial value read/write kbcomp is an 8-bit readable/writable register that selects the functions of sci2 and the a/d converter. kbcomp is initialized to h'00 by a reset and in hardware standby mode. bit 7irda enable (ire): specifies normal sci operation or irda operation for sci2 input/output. bit 7 ire description 0 the txd2/irtxd and rxd2/irrxd pins function as txd2 and rxd2 (initial value) 1 the txd2/irtxd and rxd2/irrxd pins function as irtxd and irrxd bits 6 to 4irda clock select 2 to 0 (ircks2 to ircks0): these bits specify the high pulse width in irtxd output pulse encoding when the irda function is enabled. bit 6 bit 5 bit 4 ircks2 ircks1 ircks0 description 000b 3/16 (3/16 of the bit rate) (initial value) 1 ?/2 1 0 ?/4 1 ?/8 1 0 0 ?/16 1 ?/32 1 0 ?/64 1 ?/128 bits 3 to 0keyboard comparator control: see the description in section 20, a/d converter.
443 15.3 operation 15.3.1 overview the sci can carry out serial communication in two modes: asynchronous mode in which synchronization is achieved character by character, and synchronous mode in which synchronization is achieved with clock pulses. selection of asynchronous or synchronous mode and the transmission format is made using smr as shown in table 15.8. the sci clock is determined by a combination of the c/ $ bit in smr and the cke1 and cke0 bits in scr, as shown in table 15.9. asynchronous mode data length: choice of 7 or 8 bits choice of parity addition, multiprocessor bit addition, and addition of 1 or 2 stop bits (the combination of these parameters determines the transfer format and character length) detection of framing, parity, and overrun errors, and breaks, during reception choice of internal or external clock as sci clock source ? when internal clock is selected: the sci operates on the baud rate generator clock and a clock with the same frequency as the bit rate can be output ? when external clock is selected: a clock with a frequency of 16 times the bit rate must be input (the built-in baud rate generator is not used) synchronous mode transfer format: fixed 8-bit data detection of overrun errors during reception choice of internal or external clock as sci clock source ? when internal clock is selected: the sci operates on the baud rate generator clock and a serial clock is output off-chip ? when external clock is selected: the built-in baud rate generator is not used, and the sci operates on the input serial clock
444 table 15.8 smr settings and serial transfer format selection smr settings sci transfer format bit 7 bit 6 bit 2 bit 5 bit 3 data multi- processor parity stop bit c/ $ $ chr mp pe stop mode length bit bit length 00000 asynchronous 8-bit data no no 1 bit 1 mode 2 bits 1 0 yes 1 bit 1 2 bits 1 0 0 7-bit data no 1 bit 1 2 bits 1 0 yes 1 bit 1 2 bits 0 1 0 asynchronous 8-bit data yes no 1 bit 1 mode (multi- 2 bits 10 processor 7-bit data 1 bit 1 format) 2 bits 1 synchronous mode 8-bit data no none table 15.9 smr and scr settings and sci clock source selection smr scr setting sci transfer clock bit 7 bit 1 bit 0 clock c/ $ $ cke1 cke0 mode source sck pin function 0 0 0 asynchronous internal sci does not use sck pin 1 mode outputs clock with same frequency as bit rate 1 0 external inputs clock with frequency of 16 times 1 the bit rate 1 0 0 synchronous internal outputs serial clock 1 mode 1 0 external inputs serial clock 1
445 15.3.2 operation in asynchronous mode in asynchronous mode, characters are sent or received, each preceded by a start bit indicating the start of communication and followed by one or two stop bits indicating the end of communication. serial communication is thus carried out with synchronization established on a character-by-character basis. inside the sci, the transmitter and receiver are independent units, enabling full-duplex communication. both the transmitter and the receiver also have a double-buffered structure, so that data can be read or written during transmission or reception, enabling continuous data transfer. figure 15.2 shows the general format for asynchronous serial communication. in asynchronous serial communication, the transmission line is usually held in the mark state (high level). the sci monitors the transmission line, and when it goes to the space state (low level), recognizes a start bit and starts serial communication. one serial communication character consists of a start bit (low level), followed by data (in lsb- first order), a parity bit (high or low level), and finally one or two stop bits (high level). in asynchronous mode, the sci performs synchronization at the falling edge of the start bit in reception. the sci samples the data on the 8th pulse of a clock with a frequency of 16 times the length of one bit, so that the transfer data is latched at the center of each bit. lsb start bit msb idle state (mark state) stop bit(s) 0 transmit/receive data d0 d1 d2 d3 d4 d5 d6 d7 0/1 1 1 1 1 serial data parity bit 1 bit 1 or 2 bits 7 or 8 bits 1 bit, or none one unit of transfer data (character or frame) figure 15.2 data format in asynchronous communication (example with 8-bit data, parity, two stop bits)
446 data transfer format: table 15.10 shows the data transfer formats that can be used in asynchronous mode. any of 12 transfer formats can be selected by settings in smr. table 15.10 serial transfer formats (asynchronous mode) smr settings serial transfer format and frame length chr pe mp stop 1 2 3 4 5 6 7 8 9 10 11 12 0000 s 8-bit data stop 0001 s 8-bit data stop stop 0100 s 8-bit data p stop 0101 s 8-bit data p stop stop 1000 s 7-bit data stop 1001 s 7-bit data stop stop 1100 s 7-bit data p stop 1101 s 7-bit data p stop stop 0 1 0 s 8-bit data mpb stop 0 1 1 s 8-bit data mpb stop stop 1 1 0 s 7-bit data mpb stop 1 1 1 s 7-bit data mpb stop stop legend: s: start bit stop: stop bit p: parity bit mpb: multiprocessor bit
447 clock: either an internal clock generated by the built-in baud rate generator or an external clock input at the sck pin can be selected as the scis serial clock, according to the setting of the c/ $ bit in smr and the cke1 and cke0 bits in scr. for details of sci clock source selection, see table 15.9. when an external clock is input at the sck pin, the clock frequency should be 16 times the bit rate used. when the sci is operated on an internal clock, the clock can be output from the sck pin. the frequency of the clock output in this case is equal to the bit rate, and the phase is such that the rising edge of the clock is at the center of each transmit data bit, as shown in figure 15.3. 0 1 frame d0 d1 d2 d3 d4 d5 d6 d7 0/1 1 1 figure 15.3 relation between output clock and transfer data phase (asynchronous mode) data transfer operations sci initialization (asynchronous mode): before transmitting and receiving data, first clear the te and re bits in scr to 0, then initialize the sci as described below. when the operating mode, transfer format, etc., is changed, the te and re bits must be cleared to 0 before making the change using the following procedure. when the te bit is cleared to 0, the tdre flag is set to 1 and tsr is initialized. note that clearing the re bit to 0 does not change the contents of the rdrf, per, fer, and orer flags, or the contents of rdr. when an external clock is used the clock should not be stopped during operation, including initialization, since operation is uncertain.
448 figure 15.4 shows a sample sci initialization flowchart. wait start initialization set data transfer format in smr and scmr [1] set cke1 and cke0 bits in scr (te, re bits 0) no yes set value in brr clear te and re bits in scr to 0 [2] [3] set te and re bits in scr to 1, and set rie, tie, teie, and mpie bits [4] 1-bit interval elapsed? [1] set the clock selection in scr. be sure to clear bits rie, tie, teie, and mpie, and bits te and re, to 0. when the clock is selected in asynchronous mode, it is output immediately after scr settings are made. [2] set the data transfer format in smr and scmr. [3] write a value corresponding to the bit rate to brr. this is not necessary if an external clock is used. [4] wait at least one bit interval, then set the te bit or re bit in scr to 1. also set the rie, tie, teie, and mpie bits. setting the te and re bits enables the txd and rxd pins to be used. figure 15.4 sample sci initialization flowchart
449 serial data transmission (asynchronous mode): figure 15.5 shows a sample flowchart for serial transmission. the following procedure should be used for serial data transmission. no [1] yes initialization start transmission read tdre flag in ssr [2] write transmit data to tdr and clear tdre flag in ssr to 0 no yes no yes read tend flag in ssr [3] no yes [4] clear dr to 0 and set ddr to 1 clear te bit in scr to 0 tdre = 1? all data transmitted? tend = 1? break output? [1] sci initialization: the txd pin is automatically designated as the transmit data output pin. after the te bit is set to 1, one frame of 1s is output and transmission is enabled. [2] sci status check and transmit data write: read ssr and check that the tdre flag is set to 1, then write transmit data to tdr and clear the tdre flag to 0. [3] serial transmission continuation procedure: to continue serial transmission, read 1 from the tdre flag to confirm that writing is possible, then write data to tdr, and then clear the tdre flag to 0. checking and clearing of the tdre flag is automatic when the dtc is activated by a transmit-data-empty interrupt (txi) request, and data is written to tdr. [4] break output at the end of serial transmission: to output a break in serial transmission, set ddr for the port corresponding to the txd pin to 1, clear dr to 0, then clear the te bit in scr to 0. figure 15.5 sample serial transmission flowchart
450 in serial transmission, the sci operates as described below. 1. the sci monitors the tdre flag in ssr, and if it is 0, recognizes that data has been written to tdr, and transfers the data from tdr to tsr. 2. after transferring data from tdr to tsr, the sci sets the tdre flag to 1 and starts transmission. if the tie bit is set to 1 at this time, a transmit data empty interrupt (txi) is generated. the serial transmit data is sent from the txd pin in the following order. a. start bit: one 0-bit is output. b. transmit data: 8-bit or 7-bit data is output in lsb-first order. c. parity bit or multiprocessor bit: one parity bit (even or odd parity), or one multiprocessor bit is output. a format in which neither a parity bit nor a multiprocessor bit is output can also be selected. d. stop bit(s): one or two 1-bits (stop bits) are output. e. mark state: 1 is output continuously until the start bit that starts the next transmission is sent. 3. the sci checks the tdre flag at the timing for sending the stop bit. if the tdre flag is cleared to 0, the data is transferred from tdr to tsr, the stop bit is sent, and then serial transmission of the next frame is started. if the tdre flag is set to 1, the tend flag in ssr is set to 1, the stop bit is sent, and then the mark state is entered in which 1 is output continuously. if the teie bit in scr is set to 1 at this time, a tei interrupt request is generated.
451 figure 15.6 shows an example of the operation for transmission in asynchronous mode. tdre tend 0 1 frame d0 d1 d7 0/1 1 0 d0 d1 d7 0/1 1 1 1 data start bit parity bit stop bit start bit data parity bit stop bit txi interrupt request generated data written to tdr and tdre flag cleared to 0 in txi interrupt handling routine tei interrupt request generated idle state (mark state) txi interrupt request generated figure 15.6 example of operation in transmission in asynchronous mode (example with 8-bit data, parity, one stop bit)
452 serial data reception (asynchronous mode): figure 15.7 shows a sample flowchart for serial reception. the following procedure should be used for serial data reception. yes [1] no initialization start reception [2] no yes read rdrf flag in ssr [4] [5] clear re bit in scr to 0 read orer, per, and fer flags in ssr error handling (continued on next page) [3] read receive data in rdr, and clear rdrf flag in ssr to 0 no yes per fer orer= 1? rdrf= 1? all data received? sci initialization: the rxd pin is automatically designated as the receive data input pin. receive error handling and break detection: if a receive error occurs, read the orer, per, and fer flags in ssr to identify the error. after performing the appropriate error handling, ensure that the orer, per, and fer flags are all cleared to 0. reception cannot be resumed if any of these flags are set to 1. in the case of a framing error, a break can be detected by reading the value of the input port corresponding to the rxd pin. sci status check and receive data read : read ssr and check that rdrf = 1, then read the receive data in rdr and clear the rdrf flag to 0. transition of the rdrf flag from 0 to 1 can also be identified by an rxi interrupt. serial reception continuation procedure: to continue serial reception, before the stop bit for the current frame is received, read the rdrf flag, read rdr, and clear the rdrf flag to 0. the rdrf flag is cleared automatically when the dtc is activated by an rxi interrupt and the rdr value is read. [1] [2] [3] [4] [5] figure 15.7 sample serial reception data flowchart
453 [3] error handling parity error handling no yes clear orer, per, and fer flags in ssr to 0 no yes no yes framing error handling no yes overrun error handling orer = 1? fer = 1? break? per = 1? clear re bit in scr to 0 figure 15.7 sample serial reception data flowchart (cont)
454 in serial reception, the sci operates as described below. 1. the sci monitors the transmission line, and if a 0 stop bit is detected, performs internal synchronization and starts reception. 2. the received data is stored in rsr in lsb-to-msb order. 3. the parity bit and stop bit are received. after receiving these bits, the sci carries out the following checks. a. parity check: the sci checks whether the number of 1 bits in the receive data agrees with the parity (even or odd) set in the o/ ( bit in smr. b. stop bit check: the sci checks whether the stop bit is 1. if there are two stop bits, only the first is checked. c. status check: the sci checks whether the rdrf flag is 0, indicating that the receive data can be transferred from rsr to rdr. if all the above checks are passed, the rdrf flag is set to 1, and the receive data is stored in rdr. if a receive error* is detected in the error check, the operation is as shown in table 15.11. note: * subsequent receive operations cannot be performed when a receive error has occurred. also note that the rdrf flag is not set to 1 in reception, and so the error flags must be cleared to 0. 4. if the rie bit in scr is set to 1 when the rdrf flag changes to 1, a receive-data-full interrupt (rxi) request is generated. also, if the rie bit in scr is set to 1 when the orer, per, or fer flag changes to 1, a receive-error interrupt (eri) request is generated.
455 table 15.11 receive errors and conditions for occurrence receive error abbreviation occurrence condition data transfer overrun error orer when the next data reception is completed while the rdrf flag in ssr is set to 1 receive data is not transferred from rsr to rdr framing error fer when the stop bit is 0 receive data is transferred from rsr to rdr parity error per when the received data differs from the parity (even or odd) set in smr receive data is transferred from rsr to rdr figure 15.8 shows an example of the operation for reception in asynchronous mode. rdrf fer 0 1 frame d0 d1 d7 0/1 1 0 d0 d1 d7 0/1 1 1 1 data start bit parity bit stop bit start bit data parity bit stop bit rxi interrupt request generated eri interrupt request generated by framing error idle state (mark state) rdr data read and rdrf flag cleared to 0 in rxi interrupt handling routine figure 15.8 example of sci operation in reception (example with 8-bit data, parity, one stop bit)
456 15.3.3 multiprocessor communication function the multiprocessor communication function performs serial communication using a multiprocessor format, in which a multiprocessor bit is added to the transfer data, in asynchronous mode. use of this function enables data transfer to be performed among a number of processors sharing transmission lines. when multiprocessor communication is carried out, each receiving station is addressed by a unique id code. the serial communication cycle consists of two component cycles: an id transmission cycle which specifies the receiving station, and a data transmission cycle. the multiprocessor bit is used to differentiate between the id transmission cycle and the data transmission cycle. the transmitting station first sends the id of the receiving station with which it wants to perform serial communication as data with a 1 multiprocessor bit added. it then sends transmit data as data with a 0 multiprocessor bit added. the receiving station skips the data until data with a 1 multiprocessor bit is sent. when data with a 1 multiprocessor bit is received, the receiving station compares that data with its own id. the station whose id matches then receives the data sent next. stations whose id does not match continue to skip the data until data with a 1 multiprocessor bit is again received. in this way, data communication is carried out among a number of processors. figure 15.9 shows an example of inter-processor communication using a multiprocessor format. data transfer format: there are four data transfer formats. when a multiprocessor format is specified, the parity bit specification is invalid. for details, see table 15.10. clock: see the section on asynchronous mode.
457 transmitting station receiving station a (id = 01) receiving station b (id = 02) receiving station c (id = 03) receiving station d (id = 04) serial communication line serial data id transmission cycle: receiving station specification data transmission cycle: data transmission to receiving station specified by id (mpb = 1) (mpb = 0) h'01 h'aa legend: mpb: multiprocessor bit figure 15.9 example of inter-processor communication using multiprocessor format (transmission of data h'aa to receiving station a)
458 data transfer operations multiprocessor serial data transmission: figure 15.10 shows a sample flowchart for multiprocessor serial data transmission. the following procedure should be used for multiprocessor serial data transmission. no [1] yes initialization start transmission read tdre flag in ssr [2] write transmit data to tdr and set mpbt bit in ssr no yes no yes read tend flag in ssr [3] no yes [4] clear dr to 0 and set ddr to 1 clear te bit in scr to 0 tdre = 1? all data transmitted? tend = 1? break output? clear tdre flag to 0 sci initialization: the txd pin is automatically designated as the transmit data output pin. after the te bit is set to 1, one frame of 1s is output and transmission is enabled. sci status check and transmit data write: read ssr and check that the tdre flag is set to 1, then write transmit data to tdr. set the mpbt bit in ssr to 0 or 1. finally, clear the tdre flag to 0. serial transmission continuation procedure: to continue serial transmission, be sure to read 1 from the tdre flag to confirm that writing is possible, then write data to tdr, and then clear the tdre flag to 0. checking and clearing of the tdre flag is automatic when the dtc is activated by a transmit- data-empty interrupt (txi) request, and data is written to tdr. break output at the end of serial transmission: to output a break in serial transmission, set the port ddr to 1, clear dr to 0, then clear the te bit in scr to 0. [1] [2] [3] [4] figure 15.10 sample multiprocessor serial transmission flowchart
459 in serial transmission, the sci operates as described below. 1. the sci monitors the tdre flag in ssr, and if it is 0, recognizes that data has been written to tdr, and transfers the data from tdr to tsr. 2. after transferring data from tdr to tsr, the sci sets the tdre flag to 1 and starts transmission. if the tie bit is set to 1 at this time, a transmit-data-empty interrupt (txi) is generated. the serial transmit data is sent from the txd pin in the following order. a. start bit: one 0-bit is output. b. transmit data: 8-bit or 7-bit data is output in lsb-first order. c. multiprocessor bit one multiprocessor bit (mpbt value) is output. d. stop bit(s): one or two 1-bits (stop bits) are output. e. mark state: 1 is output continuously until the start bit that starts the next transmission is sent. 3. the sci checks the tdre flag at the timing for sending the stop bit. if the tdre flag is cleared to 0, data is transferred from tdr to tsr, the stop bit is sent, and then serial transmission of the next frame is started. if the tdre flag is set to 1, the tend flag in ssr is set to 1, the stop bit is sent, and then the mark state is entered in which 1 is output continuously. if the teie bit in scr is set to 1 at this time, a transmit-end interrupt (tei) request is generated.
460 figure 15.11 shows an example of sci operation for transmission using a multiprocessor format. tdre tend 0 1 frame d0 d1 d7 0/1 1 0 d0 d1 d7 0/1 1 1 1 data start bit multi- proce- ssor bit stop bit start bit data multi- proces- sor bit stop bit txi interrupt request generated data written to tdr and tdre flag cleared to 0 in txi interrupt handling routine tei interrupt request generated idle state (mark state) txi interrupt request generated figure 15.11 example of sci operation in transmission (example with 8-bit data, multiprocessor bit, one stop bit)
461 multiprocessor serial data reception: figure 15.12 shows a sample flowchart for multiprocessor serial reception. the following procedure should be used for multiprocessor serial data reception. yes [1] no initialization start reception no yes [4] clear re bit in scr to 0 error handling (continued on next page) [5] no yes fer orer = 1? rdrf = 1? all data received? read mpie bit in scr [2] read orer and fer flags in ssr read rdrf flag in ssr [3] read receive data in rdr no yes this station's id? read orer and fer flags in ssr yes no read rdrf flag in ssr no yes fer orer = 1? read receive data in rdr rdrf = 1? sci initialization: the rxd pin is automatically designated as the receive data input pin. id reception cycle: set the mpie bit in scr to 1. sci status check, id reception and comparison: read ssr and check that the rdrf flag is set to 1, then read the receive data in rdr and compare it with this station? id. if the data is not this station? id, set the mpie bit to 1 again, and clear the rdrf flag to 0. if the data is this station? id, clear the rdrf flag to 0. sci status check and data reception: read ssr and check that the rdrf flag is set to 1, then read the data in rdr. receive error handling and break detection: if a receive error occurs, read the orer and fer flags in ssr to identify the error. after performing the appropriate error handling, ensure that the orer and fer flags are both cleared to 0. reception cannot be resumed if either of these flags is set to 1. in the case of a framing error, a break can be detected by reading the rxd pin value. [1] [2] [3] [4] [5] figure 15.12 sample multiprocessor serial reception flowchart
462 error handling yes no clear orer, per, and fer flags in ssr to 0 no yes no yes framing error handling overrun error handling orer = 1? fer = 1? break? clear re bit in scr to 0 [5] figure 15.12 sample multiprocessor serial reception flowchart (cont)
463 figure 15.13 shows an example of sci operation for multiprocessor format reception. mpie rdr value 0 d0 d1 d7 1 1 0 d0 d1 d7 0 1 1 1 data (id1) start bit mpb stop bit start bit data (data1) mpb stop bit rxi interrupt request (multiprocessor interrupt) generated mpie = 0 idle state (mark state) rdrf rdr data read and rdrf flag cleared to 0 in rxi interrupt handling routine if not this station? id, mpie bit is set to 1 again rxi interrupt request is not generated, and rdr retains its state id1 (a) data does not match station? id mpie rdr value 0 d0 d1 d7 1 1 0 d0 d1 d7 0 1 1 1 data (id2) start bit mpb stop bit start bit data (data2) mpb stop bit rxi interrupt request (multiprocessor interrupt) generated mpie = 0 idle state (mark state) rdrf rdr data read and rdrf flag cleared to 0 in rxi interrupt handling routine matches this station? id, so reception continues, and data is received in rxi interrupt handling routine mpie bit set to 1 again id2 (b) data matches station? id data2 id1 figure 15.13 example of sci operation in reception (example with 8-bit data, multiprocessor bit, one stop bit)
464 15.3.4 operation in synchronous mode in synchronous mode, data is transmitted or received in synchronization with clock pulses, making it suitable for high-speed serial communication. inside the sci, the transmitter and receiver are independent units, enabling full-duplex communication by use of a common clock. both the transmitter and the receiver also have a double-buffered structure, so that data can be read or written during transmission or reception, enabling continuous data transfer. figure 15.14 shows the general format for synchronous serial communication. don? care don? care one unit of transfer data (character or frame) bit 0 serial data serial clock bit 1 bit 3 bit 4 bit 5 lsb msb bit 2 bit 6 bit 7 * note: * high except in continuous transfer * figure 15.14 data format in synchronous communication in synchronous serial communication, data on the transmission line is output from one falling edge of the serial clock to the next. data is guaranteed valid at the rising edge of the serial clock. in synchronous serial communication, one character consists of data output starting with the lsb and ending with the msb. after the msb is output, the transmission line holds the msb state. in synchronous mode, the sci receives data in synchronization with the rising edge of the serial clock.
465 data transfer format: a fixed 8-bit data format is used. no parity or multiprocessor bits are added. clock: either an internal clock generated by the built-in baud rate generator or an external serial clock input at the sck pin can be selected, according to the setting of the c/ $ bit in smr and the cke1 and cke0 bits in scr. for details on sci clock source selection, see table 15.9. when the sci is operated on an internal clock, the serial clock is output from the sck pin. eight serial clock pulses are output in the transfer of one character, and when no transfer is performed the clock is fixed high. when only receive operations are performed, however, the serial clock is output until an overrun error occurs or the re bit is cleared to 0. to perform receive operations in units of one character, select an external clock as the clock source. data transfer operations sci initialization (synchronous mode): before transmitting and receiving data, first clear the te and re bits in scr to 0, then initialize the sci as described below. when the operating mode, transfer format, etc., is changed, the te and re bits must be cleared to 0 before making the change using the following procedure. when the te bit is cleared to 0, the tdre flag is set to 1 and tsr is initialized. note that clearing the re bit to 0 does not change the settings of the rdrf, per, fer, and orer flags, or the contents of rdr. figure 15.15 shows a sample sci initialization flowchart.
466 wait start initialization set data transfer format in smr and scmr no yes set value in brr note: in simultaneous transmit and receive operations, the te bit and re bit should both be cleared to 0 or set to 1 simultaneously. clear te and re bits in scr to 0 [2] [3] set te and re bits in scr to 1, and set rie, tie, teie, and mpie bits [4] 1-bit interval elapsed? set cke1 and cke0 bits in scr (te, re bits 0) [1] [1] set the clock selection in scr. be sure to clear bits rie, tie, teie, and mpie, te and re, to 0. [2] set the data transfer format in smr and scmr. [3] write a value corresponding to the bit rate to brr. this is not necessary if an external clock is used. [4] wait at least one bit interval, then set the te bit or re bit in scr to 1. also set the rie, tie, teie, and mpie bits. setting the te and re bits enables the txd and rxd pins to be used. figure 15.15 sample sci initialization flowchart
467 serial data transmission (synchronous mode): figure 15.16 shows a sample flowchart for serial transmission. the following procedure should be used for serial data transmission. no [1] yes initialization start transmission read tdre flag in ssr [2] write transmit data to tdr and clear tdre flag in ssr to 0 no yes no yes read tend flag in ssr [3] clear te bit in scr to 0 tdre = 1? all data transmitted? tend = 1? [1] sci initialization: the txd pin is automatically designated as the transmit data output pin. [2] sci status check and transmit data write: read ssr and check that the tdre flag is set to 1, then write transmit data to tdr and clear the tdre flag to 0. [3] serial transmission continuation procedure: to continue serial transmission, be sure to read 1 from the tdre flag to confirm that writing is possible, then write data to tdr, and then clear the tdre flag to 0. checking and clearing of the tdre flag is automatic when the dtc is activated by a transmit-data-empty interrupt (txi) request and data is written to tdr. figure 15.16 sample serial transmission flowchart
468 in serial transmission, the sci operates as described below. 1. the sci monitors the tdre flag in ssr, and if it is 0, recognizes that data has been written to tdr, and transfers the data from tdr to tsr. 2. after transferring data from tdr to tsr, the sci sets the tdre flag to 1 and starts transmission. if the tie bit is set to 1 at this time, a transmit-data-empty interrupt (txi) is generated. when clock output mode has been set, the sci outputs 8 serial clock pulses. when use of an external clock has been specified, data is output synchronized with the input clock. the serial transmit data is sent from the txd pin starting with the lsb (bit 0) and ending with the msb (bit 7). 3. the sci checks the tdre flag at the timing for sending the msb (bit 7). if the tdre flag is cleared to 0, data is transferred from tdr to tsr, and serial transmission of the next frame is started. if the tdre flag is set to 1, the tend flag in ssr is set to 1, the msb (bit 7) is sent, and the txd pin maintains its state. if the teie bit in scr is set to 1 at this time, a transmit-end interrupt (tei) request is generated. 4. after completion of serial transmission, the sck pin is held in a constant state. figure 15.17 shows an example of sci operation in transmission. transfer direction bit 0 serial data serial clock 1 frame tdre tend bit 1 bit 7 bit 0 bit 1 bit 7 bit 6 data written to tdr and tdre flag cleared to 0 in txi interrupt handling routine tei interrupt request generated txi interrupt request generated txi interrupt request generated figure 15.17 example of sci operation in transmission
469 serial data reception (synchronous mode): figure 15.18 shows a sample flowchart for serial reception. the following procedure should be used for serial data reception. when changing the operating mode from asynchronous to synchronous, be sure to check that the orer, per, and fer flags are all cleared to 0. the rdrf flag will not be set if the fer or per flag is set to 1, and neither transmit nor receive operations will be possible. yes [1] no initialization start reception [2] no yes read rdrf flag in ssr [4] [5] clear re bit in scr to 0 error handling (continued below) [3] read receive data in rdr, and clear rdrf flag in ssr to 0 no yes orer= 1? rdrf= 1? all data received? read orer flag in ssr [1] [2] [3] [4] [5] sci initialization: the rxd pin is automatically designated as the receive data input pin. receive error handling: if a receive error occurs, read the orer flag in ssr , and after performing the appropriate error handling, clear the orer flag to 0. transfer cannot be resumed if the orer flag is set to 1. sci status check and receive data read: read ssr and check that the rdrf flag is set to 1, then read the receive data in rdr and clear the rdrf flag to 0. transition of the rdrf flag from 0 to 1 can also be identified by an rxi interrupt. serial reception continuation procedure: to continue serial reception, before the msb (bit 7) of the current frame is received, finish reading the rdrf flag, reading rdr, and clearing the rdrf flag to 0. the rdrf flag is cleared automatically when the dtc is activated by a receive-data-full interrupt (rxi) request and the rdr value is read. error handling overrun error handling [3] clear orer flag in ssr to 0 figure 15.18 sample serial reception flowchart
470 in serial reception, the sci operates as described below. 1. the sci performs internal initialization in synchronization with serial clock input or output. 2. the received data is stored in rsr in lsb-to-msb order. after reception, the sci checks whether the rdrf flag is 0 and the receive data can be transferred from rsr to rdr. if this check is passed, the rdrf flag is set to 1, and the receive data is stored in rdr. if a receive error is detected in the error check, the operation is as shown in table 15.11. neither transmit nor receive operations can be performed subsequently when a receive error has been found in the error check. 3. if the rie bit in scr is set to 1 when the rdrf flag changes to 1, a receive-data-full interrupt (rxi) request is generated. also, if the rie bit in scr is set to 1 when the orer flag changes to 1, a receive-error interrupt (eri) request is generated. figure 15.19 shows an example of sci operation in reception. bit 7 serial data serial clock 1 frame rdrf orer bit 0 bit 7 bit 0 bit 1 bit 6 bit 7 rxi interrupt request generated rdr data read and rdrf flag cleared to 0 in rxi interrupt handling routine rxi interrupt request generated eri interrupt request generated by overrun error figure 15.19 example of sci operation in reception
471 simultaneous serial data transmission and reception (synchronous mode): figure 15.20 shows a sample flowchart for simultaneous serial transmit and receive operations. the following procedure should be used for simultaneous serial data transmit and receive operations. yes [1] no initialization start transmission/reception [5] error handling [3] read receive data in rdr, and clear rdrf flag in ssr to 0 no yes orer = 1? all data received? [2] read tdre flag in ssr no yes tdre = 1? write transmit data to tdr and clear tdre flag in ssr to 0 no yes rdrf = 1? read orer flag in ssr [4] read rdrf flag in ssr clear te and re bits in scr to 0 note: when switching from transmit or receive operation to simultaneous transmit and receive operations, first clear the te bit and re bit to 0, then set both these bits to 1 simultaneously. [1] [2] [3] [4] [5] sci initialization: the txd pin is designated as the transmit data output pin, and the rxd pin is designated as the receive data input pin, enabling simultaneous transmit and receive operations. sci status check and transmit data write: read ssr and check that the tdre flag is set to 1, then write transmit data to tdr and clear the tdre flag to 0. transition of the tdre flag from 0 to 1 can also be identified by a txi interrupt. receive error handling: if a receive error occurs, read the orer flag in ssr , and after performing the appropriate error handling, clear the orer flag to 0. transmission/reception cannot be resumed if the orer flag is set to 1. sci status check and receive data read: read ssr and check that the rdrf flag is set to 1, then read the receive data in rdr and clear the rdrf flag to 0. transition of the rdrf flag from 0 to 1 can also be identified by an rxi interrupt. serial transmission/reception continuation procedure: to continue serial transmission/ reception, before the msb (bit 7) of the current frame is received, finish reading the rdrf flag, reading rdr, and clearing the rdrf flag to 0. also, before the msb (bit 7) of the current frame is transmitted, read 1 from the tdre flag to confirm that writing is possible, then write data to tdr and clear the tdre flag to 0. checking and clearing of the tdre flag is automatic when the dtc is activated by a transmit-data-empty interrupt (txi) request and data is written to tdr. also, the rdrf flag is cleared automatically when the dtc is activated by a receive-data- full interrupt (rxi) request and the rdr value is read. figure 15.20 sample flowchart of simultaneous serial transmit and receive operations
472 15.3.5 irda operation figure 15.21 shows a block diagram of the irda function. when the irda function is enabled with bit ire in kbcomp, the sci channel 2 txd2 and rxd2 signals are subjected to waveform encoding/decoding conforming to irda specification version 1.0 (irtxd and irrxd pins). by connecting these pins to an infrared transceiver/receiver, it is possible to implement infrared transmission/reception conforming to the irda specification version 1.0 system. in the irda specification version 1.0 system, communication is started at a transfer rate of 9600 bps, and subsequently the transfer rate can be varied as necessary. as the irda interface in the h8s/2148 series and h8s/2144 series does not include a function for varying the transfer rate automatically, the transfer rate setting must be changed by software. irda pulse encoder pulse decoder kbcomp txd2/irtxd rxd2/irrxd sci2 txd rxd figure 15.21 block diagram of irda function transmission: in transmission, the output signal (uart frame) from the sci is converted to an ir frame by the irda interface (see figure 15.22). when the serial data is 0, a high-level pulses of 3/16 the bit rate (interval equivalent to the width of one bit) is output (initial value). the high-level pulse can be varied according to the setting of bits ircks2 to ircks0 in kbcomp. the high-level pulse width is fixed at a minimum of 1.41 s, and a maximum of (3/16 + 2.5%) bit rate or (3/16 bit rate) + 1.08 s. when system clock ? is 20 mhz, 1.6 s can be set as the minimum high-level pulse width at 1.41 s or above.
473 when the serial data is 1, no pulse is output. 0000 0 uart frame uart frame data data start bit stop bit start bit stop bit 11 111 0000 0 11 111 pulse width is 1.6 s to 3/16 bit interval transmission reception bit interval figure 15.22 irda transmit/receive operations reception: in reception, ir frame data is converted to a uart frame by the irda interface, and input to the sci. when a high-level pulse is detected, 0 data is output, and if there is no pulse during a one-bit interval, 1 data is output. note that a pulse shorter than the minimum pulse width of 1.41 s will be identified as a 0 signal. high-level pulse width selection: table 15.12 shows possible settings for bits ircks2 to ircks0 (minimum pulse width), and h8s/2148 series and h8s/2144 series operating frequencies and bit rates, for making the pulse width shorter than 3/16 times the bit rate in transmission.
474 table 15.12 bit ircks2 to ircks0 settings operating bit rate (bps) (upper row) / bit interval 3/16 (s) (lower row) frequency 2400 9600 19200 38400 57600 115200 ? (mhz) 78.13 19.53 9.77 4.88 3.26 1.63 2 010 010 010 010 010 2.097152 010 010 010 010 010 2.4576 010 010 010 010 010 3 011 011 011 011 011 3.6864 011 011 011 011 011 011 4.9152 011 011 011 011 011 011 5 011 011 011 011 011 011 6 100 100 100 100 100 100 6.144 100 100 100 100 100 100 7.3728 100 100 100 100 100 100 8 100 100 100 100 100 100 9.8304 100 100 100 100 100 100 10 100 100 100 100 100 100 12 101 101 101 101 101 101 12.288 101 101 101 101 101 101 14 101 101 101 101 101 101 14.7456 101 101 101 101 101 101 16 101 101 101 101 101 101 16.9344 101 101 101 101 101 101 17.2032 101 101 101 101 101 101 18 101 101 101 101 101 101 19.6608 101 101 101 101 101 101 20 101 101 101 101 101 101 legend: : an sci bit rate setting cannot be mode.
475 15.4 sci interrupts the sci has four interrupt sources: the transmit-end interrupt (tei) request, receive-error interrupt (eri) request, receive-data-full interrupt (rxi) request, and transmit-data-empty interrupt (txi) request. table 15.13 shows the interrupt sources and their relative priorities. individual interrupt sources can be enabled or disabled with the tie, rie, and teie bits in scr. each kind of interrupt request is sent to the interrupt controller independently. when the tdre flag in ssr is set to 1, a txi interrupt request is generated. when the tend flag in ssr is set to 1, a tei interrupt request is generated. a txi interrupt can activate the dtc to perform data transfer. the tdre flag is cleared to 0 automatically when data transfer is performed by the dtc. the dtc cannot be activated by a tei interrupt request. when the rdrf flag in ssr is set to 1, an rxi interrupt request is generated. when the orer, per, or fer flag in ssr is set to 1, an eri interrupt request is generated. an rxi interrupt can activate the dtc to perform data transfer. the rdrf flag is cleared to 0 automatically when data transfer is performed by the dtc. the dtc cannot be activated by an eri interrupt request. table 15.13 sci interrupt sources channel interrupt source description dtc activation priority * 0 eri receive error (orer, fer, or per) not possible high rxi receive data register full (rdrf) possible txi transmit data register empty (tdre) possible tei transmit end (tend) not possible 1 eri receive error (orer, per, or per) not possible rxi receive data register full (rdrf) possible txi transmit data register empty (tdre) possible tei transmit end (tend) not possible 2 eri receive error (orer, per, or per) not possible rxi receive data register full (rdrf) possible txi transmit data register empty (tdre) possible tei transmit end (tend) not possible low note: * the table shows the initial state immediately after a reset. relative channel priorities can be changed by the interrupt controller.
476 the tei interrupt is requested when the tend flag is set to 1 while the teie bit is set to 1. the tend flag is cleared at the same time as the tdre flag. consequently, if a tei interrupt and a txi interrupt are requested simultaneously, the txi interrupt will have priority for acceptance, and the tdre flag and tend flag may be cleared. note that the tei interrupt will not be accepted in this case. 15.5 usage notes the following points should be noted when using the sci. relation between writes to tdr and the tdre flag the tdre flag in ssr is a status flag that indicates that transmit data has been transferred from tdr to tsr. when the sci transfers data from tdr to tsr, the tdre flag is set to 1. data can be written to tdr regardless of the state of the tdre flag. however, if new data is written to tdr when the tdre flag is cleared to 0, the data stored in tdr will be lost since it has not yet been transferred to tsr. it is therefore essential to check that the tdre flag is set to 1 before writing transmit data to tdr. operation when multiple receive errors occur simultaneously if a number of receive errors occur at the same time, the state of the status flags in ssr is as shown in table 15.14. if there is an overrun error, data is not transferred from rsr to rdr, and the receive data is lost. table 15.14 state of ssr status flags and transfer of receive data ssr status flags receive data transfer rdrf orer fer per rsr to rdr receive errors 1 1 0 0 x overrun error 0 0 1 0 o framing error 0 0 0 1 o parity error 1 1 1 0 x overrun error + framing error 1 1 0 1 x overrun error + parity error 0 0 1 1 o framing error + parity error 1 1 1 1 x overrun error + framing error + parity error notes: o: receive data is transferred from rsr to rdr. x: receive data is not transferred from rsr to rdr.
477 break detection and processing: when a framing error (fer) is detected, a break can be detected by reading the rxd pin value directly. in a break, the input from the rxd pin becomes all 0s, and so the fer flag is set, and the parity error flag (per) may also be set. note that, since the sci continues the receive operation after receiving a break, even if the fer flag is cleared to 0, it will be set to 1 again. sending a break: the txd pin has a dual function as an i/o port whose direction (input or output) is determined by dr and ddr. this feature can be used to send a break. between serial transmission initialization and setting of the te bit to 1, the mark state is replaced by the value of dr (the pin does not function as the txd pin until the te bit is set to 1). consequently, ddr and dr for the port corresponding to the txd pin should first be set to 1. to send a break during serial transmission, first clear dr to 0, then clear the te bit to 0. when the te bit is cleared to 0, the transmitter is initialized regardless of the current transmission state, the txd pin becomes an i/o port, and 0 is output from the txd pin. receive error flags and transmit operations (synchronous mode only): transmission cannot be started when a receive error flag (orer, per, or fer) is set to 1, even if the tdre flag is cleared to 0. be sure to clear the receive error flags to 0 before starting transmission. note also that receive error flags cannot be cleared to 0 even if the re bit is cleared to 0. receive data sampling timing and reception margin in asynchronous mode: in asynchronous mode, the sci operates on a base clock with a frequency of 16 times the transfer rate. in reception, the sci samples the falling edge of the start bit using the base clock, and performs internal synchronization. receive data is latched internally at the rising edge of the 8th pulse of the base clock. this is illustrated in figure 15.23.
478 internal base clock 16 clocks 8 clocks receive data (rxd) synchronization sampling timing start bit d0 d1 data sampling timing 15 0 7 15 0 07 figure 15.23 receive data sampling timing in asynchronous mode thus the receive margin in asynchronous mode is given by equation (1) below. m = 0.5 ? 1 2n d ?0.5 n ?(l ?0.5)f ? (1 + f) 100% .......... (1) where m: receive margin (%) n: ratio of bit rate to clock (n = 16) d: clock duty (d = 0 to 1.0) l: frame length (l = 9 to 12) f: absolute value of clock rate deviation assuming values of f = 0 and d = 0.5 in equation (1), a receive margin of 46.875% is given by equation (2) below. when d = 0.5 and f = 0, m = 1 2 16 100% = 46.875% 0.5 .......... (2) however, this is only a theoretical value, and a margin of 20% to 30% should be allowed in system design.
479 restrictions on use of dtc when an external clock source is used as the serial clock, the transmit clock should not be input until at least 5 ? clock cycles after tdr is updated by the dtc. misoperation may occur if the transmit clock is input within 4 clock cycles after tdr is updated. (figure 15.24) when rdr is read by the dtc, be sure to set the activation source to the relevant sci receive-data-full interrupt (rxi). t d0 lsb serial data sck d1 d3 d4 d5 d2 d6 d7 note: when operating on an external clock, set t > 4 states. tdre figure 15.24 example of synchronous transmission by dtc
480
481 section 16 i 2 c bus interface [h8s/2148 series option] a two-channel i 2 c bus interface is available as an option in the h8s/2148 series. the i 2 c bus interface is not available for the h8s/2144 series. observe the following notes when using this option. 1. for mask-rom versions, a w is added to the part number in products in which this optional function is used. examples: hd6432147wf 2. the product number is identical for f-ztat versions. however, be sure to inform your hitachi sales representative if you will be using this option. 16.1 overview a two-channel i 2 c bus interface is available for the h8s/2148 series as an option. the i 2 c bus interface conforms to and provides a subset of the philips i 2 c bus (inter-ic bus) interface functions. the register configuration that controls the i 2 c bus differs partly from the philips configuration, however. each i 2 c bus interface channel uses only one data line (sda) and one clock line (scl) to transfer data, saving board and connector space. 16.1.1 features selection of addressing format or non-addressing format ? i 2 c bus format: addressing format with acknowledge bit, for master/slave operation ? serial format: non-addressing format without acknowledge bit, for master operation only conforms to philips i 2 c bus interface (i 2 c bus format) two ways of setting slave address (i 2 c bus format) start and stop conditions generated automatically in master mode (i 2 c bus format) selection of acknowledge output levels when receiving (i 2 c bus format) automatic loading of acknowledge bit when transmitting (i 2 c bus format) wait function in master mode (i 2 c bus format) a wait can be inserted by driving the scl pin low after data transfer, excluding acknowledgement. the wait can be cleared by clearing the interrupt flag. wait function in slave mode (i 2 c bus format) a wait request can be generated by driving the scl pin low after data transfer, excluding acknowledgement. the wait request is cleared when the next transfer becomes possible. three interrupt sources
482 ? data transfer end (including transmission mode transition with i 2 c bus format and address reception after loss of master arbitration) ? address match: when any slave address matches or the general call address is received in slave receive mode (i 2 c bus format) ? stop condition detection selection of 16 internal clocks (in master mode) direct bus drive (with scl and sda pins) ? two pinsp52/scl0 and p97/sda0(normally nmos push-pull outputs) function as nmos open-drain outputs when the bus drive function is selected. ? two pinsp86/scl1 and p42/sda1(normally cmos pins) function as nmos-only outputs when the bus drive function is selected. automatic switching from formatless mode to i 2 c bus format (channel 0 only) ? formatless operation (no start/stop conditions, non-addressing mode) in slave mode ? operation using a common data pin (sda) and independent clock pins (vsynci, scl) ? ? automatic switching from formatless mode to i 2 c bus format on the fall of the scl pin
483 16.1.2 block diagram figure 16.1 shows a block diagram of the i 2 c bus interface. figure 16.2 shows an example of i/o pin connections to external circuits. channel 0 i/o pins and channel 1 i/o pins differ in structure, and have different specifications for permissible applied voltages. for details, see section 25, electrical characteristics. ps noise canceler noise canceler clock control formatless dedicated clock (channel 0 only) bus state decision circuit arbitration decision circuit output data control circuit address comparator sar, sarx interrupt generator icdrs icdrr icdrt icsr icmr iccr internal data bus interrupt request scl sda legend: iccr: icmr: icsr: icdr: sar: sarx: ps: i 2 c bus control register i 2 c bus mode register i 2 c bus status register i 2 c bus data register slave address register slave address register x prescaler figure 16.1 block diagram of i 2 c bus interface
484 scl in scl out sda in sda out (slave 1) scl sda scl in scl out sda in sda out (slave 2) scl sda scl in scl out sda in sda out (master) h8s/2148 series chip scl sda vcc vcc scl sda figure 16.2 i 2 c bus interface connections (example: h8s/2148 series chip as master) 16.1.3 input/output pins table 16.1 summarizes the input/output pins used by the i 2 c bus interface. table 16.1 i 2 c bus interface pins channel name abbreviation * i/o function 0 serial clock scl0 i/o iic0 serial clock input/output serial data sda0 i/o iic0 serial data input/output formatless serial clock vsynci input iic0 formatless serial clock input 1 serial clock scl1 i/o iic1 serial clock input/output serial data sda1 i/o iic1 serial data input/output note: * in the text, the channel subscript is omitted, and only scl and sda are used.
485 16.1.4 register configuration table 16.2 summarizes the registers of the i 2 c bus interface. table 16.2 register configuration channel name abbreviation r/w initial value address * 1 0i 2 c bus control register iccr0 r/w h'01 h'ffd8 i 2 c bus status register icsr0 r/w h'00 h'ffd9 i 2 c bus data register icdr0 r/w h'ffde * 2 i 2 c bus mode register icmr0 r/w h'00 h'ffdf * 2 slave address register sar0 r/w h'00 h'ffdf * 2 second slave address register sarx0 r/w h'01 h'ffde * 2 1i 2 c bus control register iccr1 r/w h'01 h'ff88 i 2 c bus status register icsr1 r/w h'00 h'ff89 i 2 c bus data register icdr1 r/w h'ff8e * 2 i 2 c bus mode register icmr1 r/w h'00 h'ff8f * 2 slave address register sar1 r/w h'00 h'ff8f * 2 second slave address register sarx1 r/w h'01 h'ff8e * 2 common serial/timer control register stcr r/w h'00 h'ffc3 ddc switch register ddcswr r/w h'0f h'fee6 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. the register that can be written or read depends on the ice bit in the i 2 c bus control register. the slave address register can be accessed when ice = 0, and the i 2 c bus mode register can be accessed when ice = 1. the i 2 c bus interface registers are assigned to the same addresses as other registers. register selection is performed by means of the iice bit in the serial/timer control register (stcr).
486 16.2 register descriptions 16.2.1 i 2 c bus data register (icdr) bit initial value read/write 7 icdr7 ? r/w 6 icdr6 ? r/w 5 icdr5 ? r/w 4 icdr4 ? r/w 3 icdr3 ? r/w 0 icdr0 ? r/w 2 icdr2 ? r/w 1 icdr1 ? r/w icdrr bit initial value read/write 7 icdrr7 ? r 6 icdrr6 ? r 5 icdrr5 ? r 4 icdrr4 ? r 3 icdrr3 ? r 0 icdrr0 ? r 2 icdrr2 ? r 1 icdrr1 ? r icdrs bit initial value read/write 7 icdrs7 ? 6 icdrs6 ? 5 icdrr5 ? 4 icdrs4 ? 3 icdrs3 ? 0 icdrs0 ? 2 icdrs2 ? 1 icdrs1 ? icdrt bit initial value read/write 7 icdrt7 ? w 6 icdrt6 ? w 5 icdrt5 ? w 4 icdrt4 ? w 3 icdrt3 ? w 0 icdrt0 ? w 2 icdrt2 ? w 1 icdrt1 ? w tdre, rdrf (internal flags) bit initial value read/write ? rdrf 0 ? tdre 0
487 icdr is an 8-bit readable/writable register that is used as a transmit data register when transmitting and a receive data register when receiving. icdr is divided internally into a shift register (icdrs), receive buffer (icdrr), and transmit buffer (icdrt). icdrs cannot be read or written by the cpu, icdrr is read-only, and icdrt is write-only. data transfers among the three registers are performed automatically in coordination with changes in the bus state, and affect the status of internal flags such as tdre and rdrf. if iic is in transmit mode and the next data is in icdrt (the tdre flag is 0) following transmission/reception of one frame of data using icdrs, data is transferred automatically from icdrt to icdrs. if iic is in receive mode and no previous data remains in icdrr (the rdrf flag is 0) following transmission/reception of one frame of data using icdrs, data is transferred automatically from icdrs to icdrr. if the number of bits in a frame, excluding the acknowledge bit, is less than 8, transmit data and receive data are stored differently. transmit data should be written justified toward the msb side when mls = 0, and toward the lsb side when mls = 1. receive data bits read from the lsb side should be treated as valid when mls = 0, and bits read from the msb side when mls = 1. icdr is assigned to the same address as sarx, and can be written and read only when the ice bit is set to 1 in iccr. the value of icdr is undefined after a reset. the tdre and rdrf flags are set and cleared under the conditions shown below. setting the tdre and rdrf flags affects the status of the interrupt flags.
488 tdre description 0 the next transmit data is in icdr (icdrt), or transmission cannot (initial value) be started [clearing conditions] when transmit data is written in icdr (icdrt) in transmit mode (trs = 1) when a stop condition is detected in the bus line state after a stop condition is issued with the i 2 c bus format or serial format selected when a stop condition is detected with the i 2 c bus format selected in receive mode (trs = 0) (a 0 write to trs during transfer is valid after reception of a frame containing an acknowledge bit) 1 the next transmit data can be written in icdr (icdrt) [setting conditions] in transmit mode (trs = 1), when a start condition is detected in the bus line state after a start condition is issued in master mode with the i 2 c bus format or serial format selected when using formatless mode in transmit mode (trs = 1) when data is transferred from icdrt to icdrs (data transfer from icdrt to icdrs when trs = 1 and tdre = 0, and icdrs is empty) when a switch is made from receive mode (trs = 0) to transmit mode (trs = 1 ) after detection of a start condition rdrf description 0 the data in icdr (icdrr) is invalid (initial value) [clearing condition] when icdr (icdrr) receive data is read in receive mode 1 the icdr (icdrr) receive data can be read [setting condition] when data is transferred from icdrs to icdrr (data transfer from icdrs to icdrr in case of normal termination with trs = 0 and rdrf = 0)
489 16.2.2 slave address register (sar) bit initial value read/write 7 sva6 0 r/w 6 sva5 0 r/w 5 sva4 0 r/w 4 sva3 0 r/w 3 sva2 0 r/w 0 fs 0 r/w 2 sva1 0 r/w 1 sva0 0 r/w sar is an 8-bit readable/writable register that stores the slave address and selects the communication format. when the chip is in slave mode (and the addressing format is selected), if the upper 7 bits of sar match the upper 7 bits of the first frame received after a start condition, the chip operates as the slave device specified by the master device. sar is assigned to the same address as icmr, and can be written and read only when the ice bit is cleared to 0 in iccr. sar is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 1slave address (sva6 to sva0): set a unique address in bits sva6 to sva0, differing from the addresses of other slave devices connected to the i 2 c bus.
490 bit 0format select (fs): used together with the fsx bit in sarx and the sw bit in ddcswr to select the communication format. i 2 c bus format: addressing format with acknowledge bit synchronous serial format: non-addressing format without acknowledge bit, for master mode only formatless mode (channel 0 only): non-addressing format with or without acknowledge bit, slave mode only, start/stop conditions not detected the fs bit also specifies whether or not sar slave address recognition is performed in slave mode. ddcswr bit 6 sar bit 0 sarx bit 0 sw fs fsx operating mode 000 i 2 c bus format sar and sarx slave addresses recognized 1i 2 c bus format sar slave address recognized sarx slave address ignored (initial value) 10 i 2 c bus format sar slave address ignored sarx slave address recognized 1 synchronous serial format sar and sarx slave addresses ignored 10 0 1 0 1 0 formatless mode (start/stop conditions not detected) acknowledge bit used 1 1 formatless mode * (start/stop conditions not detected) no acknowledge bit note: * do not set this mode when automatic switching to the i 2 c bus format is performed by means of the ddcswr setting.
491 16.2.3 second slave address register (sarx) bit initial value read/write 7 svax6 0 r/w 6 svax5 0 r/w 5 svax4 0 r/w 4 svax3 0 r/w 3 svax2 0 r/w 0 fsx 1 r/w 2 svax1 0 r/w 1 svax0 0 r/w sarx is an 8-bit readable/writable register that stores the second slave address and selects the communication format. when the chip is in slave mode (and the addressing format is selected), if the upper 7 bits of sarx match the upper 7 bits of the first frame received after a start condition, the chip operates as the slave device specified by the master device. sarx is assigned to the same address as icdr, and can be written and read only when the ice bit is cleared to 0 in iccr. sarx is initialized to h'01 by a reset and in hardware standby mode. bits 7 to 1second slave address (svax6 to svax0): set a unique address in bits svax6 to svax0, differing from the addresses of other slave devices connected to the i 2 c bus. bit 0format select x (fsx): used together with the fs bit in sar and the sw bit in ddcswr to select the communication format. i 2 c bus format: addressing format with acknowledge bit synchronous serial format: non-addressing format without acknowledge bit, for master mode only formatless mode: non-addressing format with or without acknowledge bit, slave mode only, start/stop conditions not detected the fsx bit also specifies whether or not sarx slave address recognition is performed in slave mode. for details, see the description of the fs bit in sar.
492 16.2.4 i 2 c bus mode register (icmr) bit initial value read/write 7 mls 0 r/w 6 wait 0 r/w 5 cks2 0 r/w 4 cks1 0 r/w 3 cks0 0 r/w 0 bc0 0 r/w 2 bc2 0 r/w 1 bc1 0 r/w icmr is an 8-bit readable/writable register that selects whether the msb or lsb is transferred first, performs master mode wait control, and selects the master mode transfer clock frequency and the transfer bit count. icmr is assigned to the same address as sar. icmr can be written and read only when the ice bit is set to 1 in iccr. icmr is initialized to h'00 by a reset and in hardware standby mode. bit 7msb-first/lsb-first select (mls): selects whether data is transferred msb-first or lsb-first. if the number of bits in a frame, excluding the acknowledge bit, is less than 8, transmit data and receive data are stored differently. transmit data should be written justified toward the msb side when mls = 0, and toward the lsb side when mls = 1. receive data bits read from the lsb side should be treated as valid when mls = 0, and bits read from the msb side when mls = 1. do not set this bit to 1 when the i 2 c bus format is used. bit 7 mls description 0 msb-first (initial value) 1 lsb-first
493 bit 6wait insertion bit (wait): selects whether to insert a wait between the transfer of data and the acknowledge bit, in master mode with the i 2 c bus format. when wait is set to 1, after the fall of the clock for the final data bit, the iric flag is set to 1 in iccr, and a wait state begins (with scl at the low level). when the iric flag is cleared to 0 in iccr, the wait ends and the acknowledge bit is transferred. if wait is cleared to 0, data and acknowledge bits are transferred consecutively with no wait inserted. the iric flag in iccr is set to 1 on completion of the acknowledge bit transfer, regardless of the wait setting. the setting of this bit is invalid in slave mode. bit 6 wait description 0 data and acknowledge bits transferred consecutively (initial value) 1 wait inserted between data and acknowledge bits
494 bits 5 to 3serial clock select (cks2 to cks0): these bits, together with the iicx1 (channel 1) or iicx0 (channel 0) bit in the stcr register, select the serial clock frequency in master mode. they should be set according to the required transfer rate. stcr bit 5 or 6 bit 5 bit 4 bit 3 transfer rate iicx cks2 cks1 cks0 clock ? = 5 mhz ? = 8 mhz ? = 10 mhz ? = 16 mhz ? = 20 mhz 0 0 0 0 ?/28 179 khz 286 khz 357 khz 571 khz * 714 khz * 1 ?/40 125 khz 200 khz 250 khz 400 khz 500 khz * 1 0 ?/48 104 khz 167 khz 208 khz 333 khz 417 khz * 1 ?/64 78.1 khz 125 khz 156 khz 250 khz 313 khz 1 0 0 ?/80 62.5 khz 100 khz 125 khz 200 khz 250 khz 1 ?/100 50.0 khz 80.0 khz 100 khz 160 khz 200 khz 1 0 ?/112 44.6 khz 71.4 khz 89.3 khz 143 khz 179 khz 1 ?/128 39.1 khz 62.5 khz 78.1 khz 125 khz 156 khz 1 0 0 0 ?/56 89.3 khz 143 khz 179 khz 286 khz 357 khz 1 ?/80 62.5 khz 100 khz 125 khz 200 khz 250 khz 1 0 ?/96 52.1 khz 83.3 khz 104 khz 167 khz 208 khz 1 ?/128 39.1 khz 62.5 khz 78.1 khz 125 khz 156 khz 1 0 0 ?/160 31.3 khz 50.0 khz 62.5 khz 100 khz 125 khz 1 ?/200 25.0 khz 40.0 khz 50.0 khz 80.0 khz 100 khz 1 0 ?/224 22.3 khz 35.7 khz 44.6 khz 71.4 khz 89.3 khz 1 ?/256 19.5 khz 31.3 khz 39.1 khz 62.5 khz 78.1 khz note: * outside the i 2 c bus interface specification range (normal mode: max. 100 khz; high-speed mode: max. 400 khz).
495 bits 2 to 0bit counter (bc2 to bc0): bits bc2 to bc0 specify the number of bits to be transferred next. with the i 2 c bus format (when the fs bit in sar or the fsx bit in sarx is 0), the data is transferred with one addition acknowledge bit. bit bc2 to bc0 settings should be made during an interval between transfer frames. if bits bc2 to bc0 are set to a value other than 000, the setting should be made while the scl line is low. the bit counter is initialized to 000 by a reset and when a start condition is detected. the value returns to 000 at the end of a data transfer, including the acknowledge bit. bit 2 bit 1 bit 0 bits/frame bc2 bc1 bc0 synchronous serial format i 2 c bus format 0 0 0 8 9 (initial value) 11 2 10 2 3 13 4 100 4 5 15 6 10 6 7 17 8
496 16.2.5 i 2 c bus control register (iccr) bit initial value read/write note: * only 0 can be written, to clear the flag. 7 ice 0 r/w 6 ieic 0 r/w 5 mst 0 r/w 4 trs 0 r/w 3 acke 0 r/w 0 scp 1 w 2 bbsy 0 r/w 1 iric 0 r/(w) * iccr is an 8-bit readable/writable register that enables or disables the i 2 c bus interface, enables or disables interrupts, selects master or slave mode and transmission or reception, enables or disables acknowledgement, confirms the i 2 c bus interface bus status, issues start/stop conditions, and performs interrupt flag confirmation. iccr is initialized to h'01 by a reset and in hardware standby mode. bit 7i 2 c bus interface enable (ice): selects whether or not the i 2 c bus interface is to be used. when ice is set to 1, port pins function as scl and sda input/output pins and transfer operations are enabled. when ice is cleared to 0, the i 2 c bus interface module is disabled. the sar and sarx registers can be accessed when ice is 0. the icmr and icdr registers can be accessed when ice is 1. bit 7 ice description 0i 2 c bus interface module disabled, with scl and sda signal pins set to port function sar and sarx can be accessed (initial value) 1i 2 c bus interface module enabled for transfer operations (pins scl and sca are driving the bus) icmr and icdr can be accessed bit 6i 2 c bus interface interrupt enable (ieic): enables or disables interrupts from the i 2 c bus interface to the cpu. bit 6 ieic description 0 interrupts disabled (initial value) 1 interrupts enabled
497 bit 5master/slave select (mst) bit 4transmit/receive select (trs) mst selects whether the i 2 c bus interface operates in master mode or slave mode. trs selects whether the i 2 c bus interface operates in transmit mode or receive mode. in master mode with the i 2 c bus format, when arbitration is lost, mst and trs are both reset by hardware, causing a transition to slave receive mode. in slave receive mode with the addressing format (fs = 0 or fsx = 0), hardware automatically selects transmit or receive mode according to the r/w bit in the first frame after a start condition. modification of the trs bit during transfer is deferred until transfer of the frame containing the acknowledge bit is completed, and the changeover is made after completion of the transfer. mst and trs select the operating mode as follows. bit 5 bit 4 mst trs operating mode 0 0 slave receive mode (initial value) 1 slave transmit mode 1 0 master receive mode 1 master transmit mode bit 5 mst description 0 slave mode [clearing conditions] 1. when 0 is written by software 2. when bus arbitration is lost after transmission is started in i 2 c bus format master mode (initial value) 1 master mode [setting conditions] 1. when 1 is written by software (in cases other than clearing condition 2) 2. when 1 is written in mst after reading mst = 0 (in case of clearing condition 2)
498 bit 4 trs description 0 receive mode [clearing conditions] 1. when 0 is written by software (in cases other than setting condition 3) 2. when 0 is written in trs after reading trs = 1 (in case of clearing condition 3) 3. when bus arbitration is lost after transmission is started in i 2 c bus format master mode 4. when the sw bit in ddcswr changes from 1 to 0 (initial value) 1 transmit mode [setting conditions] 1. when 1 is written by software (in cases other than clearing conditions 3 and 4) 2. when 1 is written in trs after reading trs = 0 (in case of clearing conditions 3 and 4) 3. when a 1 is received as the r/w bit of the first frame in i 2 c bus format slave mode bit 3acknowledge bit judgement selection (acke): specifies whether the value of the acknowledge bit returned from the receiving device when using the i 2 c bus format is to be ignored and continuous transfer is performed, or transfer is to be aborted and error handling, etc., performed if the acknowledge bit is 1. when the acke bit is 0, the value of the received acknowledge bit is not indicated by the ackb bit, which is always 0. in the h8s/2148 series, the dtc can be used to perform continuous transfer. the dtc is activated when the irtr interrupt flag is set to 1 (irtr is one of two interrupt flags, the other being iric). when the acke bit is 0, the tdre, iric, and irtr flags are set on completion of data transmission, regardless of the value of the acknowledge bit. when the acke bit is 1, the tdre, iric, and irtr flags are set on completion of data transmission when the acknowledge bit is 0, and the iric flag alone is set on completion of data transmission when the acknowledge bit is 1. when the dtc is activated, the tdre, iric, and irtr flags are cleared to 0 after the specified number of data transfers have been executed. consequently, interrupts are not generated during continuous data transfer, but if data transmission is completed with a 1 acknowledge bit when the acke bit is set to 1, the dtc is not activated and an interrupt is generated, if enabled. depending on the receiving device, the acknowledge bit may be significant, in indicating completion of processing of the received data, for instance, or may be fixed at 1 and have no significance.
499 bit 3 acke description 0 the value of the acknowledge bit is ignored, and continuous transfer is performed (initial value) 1 if the acknowledge bit is 1, continuous transfer is interrupted bit 2bus busy (bbsy): the bbsy flag can be read to check whether the i 2 c bus (scl, sda) is busy or free. in master mode, this bit is also used to issue start and stop conditions. a high-to-low transition of sda while scl is high is recognized as a start condition, setting bbsy to 1. a low-to-high transition of sda while scl is high is recognized as a stop condition, clearing bbsy to 0. to issue a start condition, use a mov instruction to write 1 in bbsy and 0 in scp. a retransmit start condition is issued in the same way. to issue a stop condition, use a mov instruction to write 0 in bbsy and 0 in scp. it is not possible to write to bbsy in slave mode; the i 2 c bus interface must be set to master transmit mode before issuing a start condition. mst and trs should both be set to 1 before writing 1 in bbsy and 0 in scp. bit 2 bbsy description 0 bus is free [clearing condition] when a stop condition is detected (initial value) 1 bus is busy [setting condition] when a start condition is detected
500 bit 1i 2 c bus interface interrupt request flag (iric): indicates that the i 2 c bus interface has issued an interrupt request to the cpu. iric is set to 1 at the end of a data transfer, when a slave address or general call address is detected in slave receive mode, when bus arbitration is lost in master transmit mode, and when a stop condition is detected. iric is set at different times depending on the fs bit in sar and the wait bit in icmr. see section 16.3.6, iric setting timing and scl control. the conditions under which iric is set also differ depending on the setting of the acke bit in iccr. iric is cleared by reading iric after it has been set to 1, then writing 0 in iric. when the dtc is used, iric is cleared automatically and transfer can be performed continuously without cpu intervention.
501 bit 1 iric description 0 waiting for transfer, or transfer in progress (initial value) [clearing conditions] 1. when 0 is written in iric after reading iric = 1 2. when icdr is written or read by the dtc (when the tdre or rdrf flag is cleared to 0) (this is not always a clearing condition; see the description of dtc operation for details) 1 interrupt requested [setting conditions] i 2 c bus format master mode 1. when a start condition is detected in the bus line state after a start condition is issued (when the tdre flag is set to 1 because of first frame transmission) 2. when a wait is inserted between the data and acknowledge bit when wait = 1 3. at the end of data transfer (at the rise of the 9th transmit/receive clock pulse, and, when a wait is inserted, at the fall of the 8th transmit/receive clock pulse) 4. when a slave address is received after bus arbitration is lost (when the al flag is set to 1) 5. when 1 is received as the acknowledge bit when the acke bit is 1 (when the ackb bit is set to 1) i 2 c bus format slave mode 1. when the slave address (sva, svax) matches (when the aas and aasx flags are set to 1) and at the end of data transfer up to the subsequent retransmission start condition or stop condition detection (when the tdre or rdrf flag is set to 1) 2. when the general call address is detected (when fs = 0 and the adz flag is set to 1) and at the end of data transfer up to the subsequent retransmission start condition or stop condition detection (when the tdre or rdrf flag is set to 1) 3. when 1 is received as the acknowledge bit when the acke bit is 1 (when the ackb bit is set to 1) 4. when a stop condition is detected (when the stop or estp flag is set to 1) synchronous serial format, and formatless mode 1. at the end of data transfer (when the tdre or rdrf flag is set to 1) 2. when a start condition is detected with serial format selected 3. when the sw bit is set to 1 in ddcswr
502 when, with the i 2 c bus format selected, iric is set to 1 and an interrupt is generated, other flags must be checked in order to identify the source that set iric to 1. although each source has a corresponding flag, caution is needed at the end of a transfer. when the tdre or rdrf internal flag is set, the readable irtr flag may or may not be set. the irtr flag (the dtc start request flag) is not set at the end of a data transfer up to detection of a retransmission start condition or stop condition after a slave address (sva) or general call address match in i 2 c bus format slave mode. even when the iric flag and irtr flag are set, the tdre or rdrf internal flag may not be set. the iric and irtr flags are not cleared at the end of the specified number of transfers in continuous transfer using the dtc. the tdre or rdrf flag is cleared, however, since the specified number of icdr reads or writes have been completed. table 16.3 shows the relationship between the flags and the transfer states.
503 table 16.3 flags and transfer states mst trs bbsy estp stop irtr aasx al aas adz ackb state 1/01/0000000000 idle state (flag clearing required) 11000000000 start condition issuance 11100100000 start condition established 11/0100000000/1 master mode wait 11/0100100000/1 master mode transmit/receive end 0010001/011/01/00 arbitration lost 00100000100 sar match by first frame in slave mode 00100000110 general call address match 00100010000 sarx match 01/0100000000/1 slave mode transmit/receive end (except after sarx match) 0 0 1/0 1 1 1 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 slave mode transmit/receive end (after sarx match) 0 1/0 0 1/0 1/0 0 0 0 0 0 0/1 stop condition detected bit 0start condition/stop condition prohibit (scp): controls the issuing of start and stop conditions in master mode. to issue a start condition, write 1 in bbsy and 0 in scp. a retransmit start condition is issued in the same way. to issue a stop condition, write 0 in bbsy and 0 in scp. this bit is always read as 1. if 1 is written, the data is not stored. bit 0 scp description 0 writing 0 issues a start or stop condition, in combination with the bbsy flag 1 reading always returns a value of 1 writing is ignored (initial value)
504 16.2.6 i 2 c bus status register (icsr) bit initial value read/write note: * only 0 can be written, to clear the flags. 7 estp 0 r/(w) * 6 stop 0 r/(w) * 5 irtr 0 r/(w) * 4 aasx 0 r/(w) * 3 al 0 r/(w) * 0 ackb 0 r/w 2 aas 0 r/(w) * 1 adz 0 r/(w) * icsr is an 8-bit readable/writable register that performs flag confirmation and acknowledge confirmation and control. icsr is initialized to h'00 by a reset and in hardware standby mode. bit 7error stop condition detection flag (estp): indicates that a stop condition has been detected during frame transfer in i 2 c bus format slave mode. bit 7 estp description 0 no error stop condition [clearing conditions] 1. when 0 is written in estp after reading estp = 1 2. when the iric flag is cleared to 0 (initial value) 1 in i 2 c bus format slave mode error stop condition detected [setting condition] when a stop condition is detected during frame transfer in other modes no meaning
505 bit 6normal stop condition detection flag (stop): indicates that a stop condition has been detected after completion of frame transfer in i 2 c bus format slave mode. bit 6 stop description 0 no normal stop condition [clearing conditions] 1. when 0 is written in stop after reading stop = 1 2. when the iric flag is cleared to 0 (initial value) 1 in i 2 c bus format slave mode normal stop condition detected [setting condition] when a stop condition is detected after completion of frame transfer in other modes no meaning bit 5i 2 c bus interface continuous transmission/reception interrupt request flag (irtr): indicates that the i 2 c bus interface has issued an interrupt request to the cpu, and the source is completion of reception/transmission of one frame in continuous transmission/reception for which dtc activation is possible. when the irtr flag is set to 1, the iric flag is also set to 1 at the same time. irtr flag setting is performed when the tdre or rdrf flag is set to 1. irtr is cleared by reading irtr after it has been set to 1, then writing 0 in irtr. irtr is also cleared automatically when the iric flag is cleared to 0. bit 5 irtr description 0 waiting for transfer, or transfer in progress [clearing conditions] 1. when 0 is written in irtr after reading irtr = 1 2. when the iric flag is cleared to 0 (initial value) 1 continuous transfer state [setting condition] in i 2 c bus interface slave mode when the tdre or rdrf flag is set to 1 when aasx = 1 in other modes when the tdre or rdrf flag is set to 1
506 bit 4second slave address recognition flag (aasx): in i 2 c bus format slave receive mode, this flag is set to 1 if the first frame following a start condition matches bits svax6 to svax0 in sarx. aasx is cleared by reading aasx after it has been set to 1, then writing 0 in aasx. aasx is also cleared automatically when a start condition is detected. bit 4 aasx description 0 second slave address not recognized [clearing conditions] 1. when 0 is written in aasx after reading aasx = 1 2. when a start condition is detected 3. in master mode (initial value) 1 second slave address recognized [setting condition] when the second slave address is detected in slave receive mode while fsx = 0 bit 3arbitration lost (al): this flag indicates that arbitration was lost in master mode. the i 2 c bus interface monitors the bus. when two or more master devices attempt to seize the bus at nearly the same time, if the i 2 c bus interface detects data differing from the data it sent, it sets al to 1 to indicate that the bus has been taken by another master. al is cleared by reading al after it has been set to 1, then writing 0 in al. in addition, al is reset automatically by write access to icdr in transmit mode, or read access to icdr in receive mode. bit 3 al description 0 bus arbitration won [clearing conditions] 1. when icdr data is written (transmit mode) or read (receive mode) 2. when 0 is written in al after reading al = 1 (initial value) 1 arbitration lost [setting conditions] 1. if the internal sda and sda pin disagree at the rise of scl in master transmit mode 2. if the internal scl line is high at the fall of scl in master transmit mode
507 bit 2slave address recognition flag (aas): in i 2 c bus format slave receive mode, this flag is set to 1 if the first frame following a start condition matches bits sva6 to sva0 in sar, or if the general call address (h'00) is detected. aas is cleared by reading aas after it has been set to 1, then writing 0 in aas. in addition, aas is reset automatically by write access to icdr in transmit mode, or read access to icdr in receive mode. bit 2 aas description 0 slave address or general call address not recognized [clearing conditions] 1. when icdr data is written (transmit mode) or read (receive mode) 2. when 0 is written in aas after reading aas = 1 3. in master mode (initial value) 1 slave address or general call address recognized [setting condition] when the slave address or general call address is detected in slave receive mode while fs = 0
508 bit 1general call address recognition flag (adz): in i 2 c bus format slave receive mode, this flag is set to 1 if the first frame following a start condition is the general call address (h'00). adz is cleared by reading adz after it has been set to 1, then writing 0 in adz. in addition, adz is reset automatically by write access to icdr in transmit mode, or read access to icdr in receive mode. bit 1 adz description 0 general call address not recognized [clearing conditions] 1. when icdr data is written (transmit mode) or read (receive mode) 2. when 0 is written in adz after reading adz = 1 3. in master mode (initial value) 1 general call address recognized [setting condition] when the general call address is detected in slave receive mode while fsx = 0 or fs = 0 bit 0acknowledge bit (ackb): stores acknowledge data. in transmit mode, after the receiving device receives data, it returns acknowledge data, and this data is loaded into ackb. in receive mode, after data has been received, the acknowledge data set in this bit is sent to the transmitting device. when this bit is read, in transmission (when trs = 1), the value loaded from the bus line (returned by the receiving device) is read. in reception (when trs = 0), the value set by internal software is read. bit 0 ackb description 0 receive mode: 0 is output at acknowledge output timing (initial value) transmit mode: indicates that the receiving device has acknowledged the data (signal is 0) 1 receive mode: 1 is output at acknowledge output timing transmit mode: indicates that the receiving device has not acknowledged the data (signal is 1)
509 16.2.7 serial/timer control register (stcr) bit initial value read/write 7 iics 0 r/w 6 iicx1 0 r/w 5 iicx0 0 r/w 4 iice 0 r/w 3 flshe 0 r/w 0 icks0 0 r/w 2 ? 0 r/w 1 icks1 0 r/w stcr is an 8-bit readable/writable register that controls register access, the i 2 c interface operating mode (when the on-chip iic option is included), and on-chip flash memory (f-ztat versions), and selects the tcnt input clock source. for details of functions not related to the i 2 c bus interface, see section 3.2.4, serial/timer control register (stcr), and the descriptions of the relevant modules. if a module controlled by stcr is not used, do not write 1 to the corresponding bit. stcr is initialized to h'00 by a reset and in hardware standby mode. bit 7i 2 c extra buffer select (iics): designates bits 7 to 4 of port a as the same kind of output buffer as scl and sda. this bit is used when implementing the i 2 c interface by software only. bit 7 iics description 0 pa7 to pa4 are normal i/o pins (initial value) 1 pa7 to pa4 are i/o pins with bus driving capability
510 bit 6i 2 c transfer select 1 (iicx1): this bit, together with bits cks2 to cks0 in icmr of iic1, selects the transfer rate in master mode. for details, see section 16.2.4, i 2 c bus mode register (icmr). bit 5i 2 c transfer select 0 (iicx0): this bit, together with bits cks2 to cks0 in icmr of iic0, selects the transfer rate in master mode. for details, see section 16.2.4, i 2 c bus mode register (icmr). bit 4i 2 c master enable (iice): controls cpu access to the i 2 c bus interface data and control registers (iccr, icsr, icdr/sarx, icmr/sar). bit 4 iice description 0 cpu access to i 2 c bus interface data and control registers is disabled (initial value) 1 cpu access to i 2 c bus interface data and control registers is enabled bit 3flash memory control register enable (flshe): controls the operation of the flash memory in f-ztat versions. for details, see section 22, rom. bit 2reserved: do not write 1 to this bit. bits 1 and 0internal clock source select 1 and 0 (icks1, icsk0): these bits, together with bits cks2 to cks0 in tcr, select the clock input to the timer counters (tcnt). for details, see section 12.2.4, timer control register (tcr).
511 16.2.8 ddc switch register (ddcswr) bit initial value read/write notes: 1. only 0 can be written, to clear the flag. 2. always read as 1. 7 swe 0 r/w 6 sw 0 r/w 5 ie 0 r/w 4 if 0 r/(w) * 1 3 clr3 1 w * 2 0 clr0 1 w * 2 2 clr2 1 w * 2 1 clr1 1 w * 2 ddcswr is an 8-bit readable/writable register that controls the iic channel 0 automatic format switching function and iic internal latch clearance. ddcswr is initialized to h'0f by a reset and in hardware standby mode. bit 7ddc mode switch enable (swe): selects the function for automatically switching iic channel 0 from formatless mode to the i 2 c bus format. bit 7 swe description 0 automatic switching of iic channel 0 from formatless mode to i 2 c bus format is disabled (initial value) 1 automatic switching of iic channel 0 from formatless mode to i 2 c bus format is enabled bit 6ddc mode switch (sw): selects either formatless mode or the i 2 c bus format for iic channel 0. bit 6 sw description 0 iic channel 0 is used with the i 2 c bus format [clearing conditions] 1. when 0 is written by software 2. when a falling edge is detected on the scl pin when swe = 1 (initial value) 1 iic channel 0 is used in formatless mode [setting condition] when 1 is written in sw after reading sw = 0
512 bit 5ddc mode switch interrupt enable bit (ie): enables or disables an interrupt request to the cpu when automatic format switching is executed for iic channel 0. bit 5 ie description 0 interrupt when automatic format switching is executed is disabled (initial value) 1 interrupt when automatic format switching is executed is enabled bit 4ddc mode switch interrupt flag (if): flag that indicates an interrupt request to the cpu when automatic format switching is executed for iic channel 0. bit 4 if description 0 no interrupt is requested when automatic format switching is executed [clearing condition] when 0 is written in if after reading if = 1 (initial value) 1 an interrupt is requested when automatic format switching is executed [setting condition] when a falling edge is detected on the scl pin when swe = 1
513 bits 3 to 0iic clear 3 to 0 (clr3 to clr0): these bits control initialization of the internal state of iic0 and iic1. these bits can only be written to; if read they will always return a value of 1. when a write operation is performed on these bits, a clear signal is generated for the internal latch circuit of the corresponding module(s), and the internal state of the iic module(s) is initialized. the write data for these bits is not retained. to perform iic clearance, bits clr3 to clr0 must be written to simultaneously using an mov instruction. do not use a bit manipulation instruction such as bclr. when clearing is required again, all the bits must be written to in accordance with the setting. bit 3 bit 2 bit 1 bit 0 clr3 clr2 clr1 clr0 description 0 0 setting prohibited 1 0 0 setting prohibited 1 iic0 internal latch cleared 1 0 iic1 internal latch cleared 1 iic0 and iic1 internal latches cleared 1 invalid setting
514 16.2.9 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers, and is used to perform module stop mode control. when the mstp4 or mstp3 bit is set to 1, operation of the corresponding iic channel is halted at the end of the bus cycle, and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrl bit 4module stop (mstp4): specifies iic channel 0 module stop mode. mstpcrl bit 4 mstp4 description 0 iic channel 0 module stop mode is cleared 1 iic channel 0 module stop mode is set (initial value) mstpcrl bit 3module stop (mstp3): specifies iic channel 1 module stop mode. mstpcrl bit 3 mstp3 description 0 iic channel 1 module stop mode is cleared 1 iic channel 1 module stop mode is set (initial value)
515 16.3 operation 16.3.1 i 2 c bus data format the i 2 c bus interface has serial and i 2 c bus formats. the i 2 c bus formats are addressing formats with an acknowledge bit. these are shown in figures 16.3 (a) and (b). the first frame following a start condition always consists of 8 bits. iic channel 0 only is capable of formatless operation, as shown in figure 16.3 (c). the serial format is a non-addressing format with no acknowledge bit. this is shown in figure 16.4. figure 16.5 shows the i 2 c bus timing. the symbols used in figures 16.3 to 16.5 are explained in table 16.4. s sla r/ w a data a a/ a p 1111 n 7 1 m (a) i 2 c bus format (fs = 0 or fsx = 0) (b) i 2 c bus format (start condition retransmission, fs = 0 or fsx = 0) n: transfer bit count (n = 1 to 8) m: transfer frame count (m 3 1) s sla r/ w a data 111 n1 7 1 m1 s sla r/ w a data a/ a p 111 n2 7 1 m2 11 1 a/ a n1 and n2: transfer bit count (n1 and n2 = 1 to 8) m1 and m2: transfer frame count (m1 and m2 3 1) 11 (c) formatless (iic0 only, fs = 0 or fsx = 0) data a a data 11 n 8 1 m 1 a/ a n: transfer bit count (n = 1 to 8) m: transfer frame count (m 3 1) figure 16.3 i 2 c bus data formats (i 2 c bus formats)
516 s data data p 11 n 8 1 m fs = 1 and fsx = 1 n: transfer bit count (n = 1 to 8) m: transfer frame count (m 3 1) figure 16.4 i 2 c bus data format (serial format) sda scl s 1-7 sla 8 r/w 9 a 1-7 data 89 1-7 89 a data p a/ a figure 16.5 i 2 c bus timing table 16.4 i 2 c bus data format symbols legend s start condition. the master device drives sda from high to low while scl is high sla slave address, by which the master device selects a slave device r/ : indicates the direction of data transfer: from the slave device to the master device when r/ : is 1, or from the master device to the slave device when r/ : is 0 a acknowledge. the receiving device (the slave in master transmit mode, or the master in master receive mode) drives sda low to acknowledge a transfer data transferred data. the bit length is set by bits bc2 to bc0 in icmr. the msb-first or lsb-first format is selected by bit mls in icmr p stop condition. the master device drives sda from low to high while scl is high
517 16.3.2 master transmit operation in i 2 c bus format master transmit mode, the master device outputs the transmit clock and transmit data, and the slave device returns an acknowledge signal. the transmission procedure and operations are described below. [1] set the ice bit in iccr to 1. set bits mls, wait, and cks2 to cks0 in icmr, and bit iicx in stcr, according to the operating mode. [2] read the bbsy flag in iccr to confirm that the bus is free, then set bits mst and trs to 1 in iccr to select master transmit mode. next, write 1 to bbsy and 0 to scp. this changes sda from high to low when scl is high, and generates the start condition. the tdre internal flag is then set to 1, and the iric and irtr flags are also set to 1. if the ieic bit in iccr has been set to 1, an interrupt request is sent to the cpu. [3] with the i 2 c bus format (when the fs bit in sar or the fsx bit in sarx is 0), the first frame data following the start condition indicates the 7-bit slave address and transmit/receive direction. write the data (slave address + r/w) to icdr. the tdre internal flag is then cleared to 0. the written address data is transferred to icdrs, and the tdre internal flag is set to 1 again. this is identified as indicating the end of the transfer, and so the iric flag is cleared to 0. the master device sequentially sends the transmit clock and the data written to icdr using the timing shown in figure 16.6. the selected slave device (i.e. the slave device with the matching slave address) drives sda low at the 9th transmit clock pulse and returns an acknowledge signal. [4] when one frame of data has been transmitted, the iric flag is set to 1 at the rise of the 9th transmit clock pulse. if the tdre internal flag has been set to 1, after one frame has been transmitted scl is automatically fixed low in synchronization with the internal clock until the next transmit data is written. [5] to continue transfer, write the next data to be transmitted into icdr. after the data has been transferred to icdrs and the tdre internal flag has been set to 1, clear the iric flag to 0. transmission of the next frame is performed in synchronization with the internal clock. data can be transmitted sequentially by repeating steps [4] and [5]. to end transmission, clear the iric flag, write h'ff dummy data to icdr after the last data has been transmitted (when icdrt does not contain the next transmit data), and then write 0 to bbsy and scp in iccr when the iric flag is set again. this changes sda from low to high when scl is high, and generates the stop condition.
518 sda (master output) sda (slave output) 2 1 2 1 4 36 58 79 bit 7 slave address bit 6 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 iric icdrt icdrs tdre scl (master output) start condition issuance interrupt request generation interrupt request generation data 1 address + r/w data 1 address + r/w [2] write bbsy = 1 and scp = 0 (start condition issuance) [3] icdr write [5] icdr write [5] iric clearance [3] iric clearance user processing slave address data 1 r/w [4] a figure 16.6 example of master transmit mode operation timing (mls = wait = 0) to transmit data continuously: [6] before the rise of the 9th transmit clock pulse for the data being transmitted, clear the iric flag to 0 and then write the next transmit data to icdr. [7] when one frame of data has been transmitted, the iric flag in iccr is set to 1 at the rise of the 9th transmit clock pulse. at the same time, the next transmit data written into icdr (icdrt) is transferred to icdrs, the tdre internal flag is set to 1, and then the next frame is transmitted in synchronization with the internal clock. data can be transmitted continuously by repeating steps [6] and [7].
519 sda (master output) sda (slave output) 2 1 23 1 4 36 58 79 bit 7 bit 6 bit 5 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 iric icdrt icdrs tdre scl (master output) interrupt request generation data 2 data 1 [6] icdr write icdr write [6] icdr write [6] iric clearance [6] iric clearance user processing data 1 data 1 data 2 data 3 data 2 [7] [7] a figure 16.7 example of master transmit mode continuous transmit operation timing (mls = wait = 0) 16.3.3 master receive operation in master receive mode, the master device outputs the receive clock, receives data, and returns an acknowledge signal. the slave device transmits data. the reception procedure and operations in master receive mode are described below. [1] clear the trs bit in iccr to 0 to switch from transmit mode to receive mode. also clear the ackb bit in icsr to 0 (acknowledge data setting). [2] when icdr is read (dummy data read), reception is started, and the receive clock is output, and data received, in synchronization with the internal clock. in order to determine the end of reception, the iric flag in iccr must be cleared beforehand. [3] the master device drives sda at the 9th receive clock pulse to return an acknowledge signal. when one frame of data has been received, the iric flag in iccr is set to 1 at the rise of the 9th receive clock pulse. if the ieic bit in iccr has been set to 1, an interrupt request is sent to the cpu. if the rdrf internal flag has been cleared to 0, it is set to 1, and the receive operation continues. if reception of the next frame ends before the icdr read/iric flag clearing in [4] is performed, scl is automatically fixed low in synchronization with the internal clock. [4] read icdr and clear the iric flag in iccr to 0. the rdrf flag is cleared to 0.
520 data can be received continuously by repeating steps [3] and [4]. as the rdrf internal flag is cleared to 0 when reception is started after initially switching from master transmit mode to master receive mode, reception of the next frame of data is started automatically. to halt reception, the trs bit must be set to 1 before the rise of the receive clock for the next frame. to halt reception, set the tsr bit to 1, read icdr, then write 0 to bbsy and scp in iccr. this changes sda from low to high when scl is high, and generates the stop condition. sda (master output) sda (slave output) 2 1 2 1 4 36 58 79 9 bit 7 bit 6 bit 5 bit 7 bit 6 bit 4 bit 3 bit 2 bit 1 bit 0 iric icdrs icdrr rdrf scl (master output) interrupt request generation master transmit mode master receive mode data 1 [1] trs cleared to 0 [2] icdr read (dummy read) [4] icdr read [4] iric clearance [2] iric clearance user processing data 1 data 1 data 2 [3] a a interrupt request generation figure 16.8 example of master receive mode operation timing (mls = wait = ackb = 0)
521 16.3.4 slave receive operation in slave receive mode, the master device outputs the transmit clock and transmit data, and the slave device returns an acknowledge signal. the reception procedure and operations in slave receive mode are described below. [1] set the ice bit in iccr to 1. set the mls bit in icmr and the mst and trs bits in iccr according to the operating mode. [2] when the start condition output by the master device is detected, the bbsy flag in iccr is set to 1. [3] when the slave address matches in the first frame following the start condition, the device operates as the slave device specified by the master device. if the 8th data bit (r/w) is 0, the trs bit in iccr remains cleared to 0, and slave receive operation is performed. [4] at the 9th clock pulse of the receive frame, the slave device drives sda low and returns an acknowledge signal. at the same time, the iric flag in iccr is set to 1. if the ieic bit in iccr has been set to 1, an interrupt request is sent to the cpu. if the rdrf internal flag has been cleared to 0, it is set to 1, and the receive operation continues. if the rdrf internal flag has been set to 1, the slave device drives scl low from the fall of the receive clock until data is read into icdr. [5] read icdr and clear the iric flag in iccr to 0. the rdrf flag is cleared to 0. receive operations can be performed continuously by repeating steps [4] and [5]. when sda is changed from low to high when scl is high, and the stop condition is detected, the bbsy flag in iccr is cleared to 0.
522 sda (master output) sda (slave output) 2 1 2 1 4 36 58 79 bit 7 bit 6 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 iric icdrs icdrr rdrf scl (master output) start condition issuance scl (slave output) interrupt request generation address + r/w address + r/w [5] icdr read [5] iric clearance user processing slave address data 1 [4] a r/w figure 16.9 example of slave receive mode operation timing (1) (mls = ackb = 0) sda (master output) sda (slave output) 2 14 36 58 79 8 79 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 1 bit 0 iric icdrs icdrr rdrf scl (master output) scl (slave output) interrupt request generation interrupt request generation data 2 data 2 data 1 data 1 [5] icdr read [5] iric clearance user processing data 2 data 1 [4] [4] a a figure 16.10 example of slave receive mode operation timing (2) (mls = ackb = 0)
523 16.3.5 slave transmit operation in slave transmit mode, the slave device outputs the transmit data, while the master device outputs the receive clock and returns an acknowledge signal. the transmission procedure and operations in slave transmit mode are described below. [1] set the ice bit in iccr to 1. set the mls bit in icmr and the mst and trs bits in iccr according to the operating mode. [2] when the slave address matches in the first frame following detection of the start condition, the slave device drives sda low at the 9th clock pulse and returns an acknowledge signal. at the same time, the iric flag in iccr is set to 1. if the ieic bit in iccr has been set to 1, an interrupt request is sent to the cpu. .if the 8th data bit (r/w) is 1, the trs bit in iccr is set to 1, and the mode changes to slave transmit mode automatically. the tdrf flag is set to 1. the slave device drives scl low from the fall of the transmit clock until icdr data is written. [3] after clearing the iric flag to 0, write data to icdr. the tdre internal flag is cleared to 0. the written data is transferred to icdrs, and the tdre internal flag and the iric and irtr flags are set to 1 again. after clearing the iric flag to 0, write the next data to icdr. the slave device sequentially sends the data written into icdr in accordance with the clock output by the master device at the timing shown in figure 16.11. [4] when one frame of data has been transmitted, the iric flag in iccr is set to 1 at the rise of the 9th transmit clock pulse. if the tdre internal flag has been set to 1, this slave device drives scl low from the fall of the transmit clock until data is written to icdr. the master device drives sda low at the 9th clock pulse, and returns an acknowledge signal. as this acknowledge signal is stored in the ackb bit in icsr, this bit can be used to determine whether the transfer operation was performed normally. when the tdre internal flag is 0, the data written into icdr is transferred to icdrs, transmission is started, and the tdre internal flag and the iric and irtr flags are set to 1 again. [5] to continue transmission, clear the iric flag to 0, then write the next data to be transmitted into icdr. the tdre flag is cleared to 0. transmit operations can be performed continuously by repeating steps [4] and [5]. to end transmission, write h'ff to icdr to release sda on the slave side. when sda is changed from low to high when scl is high, and the stop condition is detected, the bbsy flag in iccr is cleared to 0.
524 sda (slave output) sda (master output) sda (slave output) 2 1 2 1 4 36 58 79 9 8 bit 7 bit 6 bit 5 bit 7 bit 6 bit 4 bit 3 bit 2 bit 1 bit 0 iric icdrs icdrt tdre scl (master output) interrupt request generation interrupt request generation slave receive mode slave transmit mode data 1 data 2 [3] iric clearance [5] iric clearance [3] icdr write [3] icdr write [5] icdr write user processing data 1 data 1 data 2 data 2 a r/w a [3] [2] interrupt request generation figure 16.11 example of slave transmit mode operation timing (mls = 0)
525 16.3.6 iric setting timing and scl control the interrupt request flag (iric) is set at different times depending on the wait bit in icmr, the fs bit in sar, and the fsx bit in sarx. if the tdre or rdrf internal flag is set to 1, scl is automatically held low after one frame has been transferred; this timing is synchronized with the internal clock. figure 16.12 shows the iric set timing and scl control. (a) when wait = 0, and fs = 0 or fsx = 0 (i 2 c bus format, no wait) scl sda iric user processing clear iric write to icdr (transmit) or read icdr (receive) 1 a 8 1 1 a 7 1 89 7 (b) when wait = 1, and fs = 0 or fsx = 0 (i 2 c bus format, wait inserted) scl sda iric user processing clear iric clear iric write to icdr (transmit) or read icdr (receive) scl sda iric user processing (c) when fs = 1 and fsx = 1 (synchronous serial format) clear iric write to icdr (transmit) or read icdr (receive) 8 89 8 7 1 8 7 1 figure 16.12 iric setting timing and scl control
526 16.3.7 automatic switching from formatless mode to i 2 c bus format setting the sw bit to 1 in ddcswr enables formatless mode to be selected as the iic0 operating mode. switching from formatless mode to the i 2 c bus format (slave mode) is performed automatically when a falling edge is detected on the scl pin. the following four preconditions are necessary for this operation: a common data pin (sda) for formatless and i 2 c bus format operation separate clock pins for formatless operation (vsynci) and i 2 c bus format operation (scl) a fixed 1 level for the scl pin during format operation settings of bits other than trs in iccr that allow i 2 c bus format operation automatic switching is performed from formatless mode to the i 2 c bus format when the sw bit in ddcswr is automatically cleared to 0 on detection of a falling edge on the scl pin. switching from the i 2 c bus format to formatless mode is achieved by having software set the sw bit in ddcswr to 1. in formatless mode, bits (such as msl and trs) that control the i 2 c bus interface operating mode must not be modified. when switching from the i 2 c bus format to formatless mode, set the trs bit to 1 or clear it to 0 according to the transmit data (transmission or reception) in formatless mode, then set the sw bit to 1. after automatic switching from formatless mode to the i 2 c bus format (slave mode), in order to wait for slave address reception, the trs bit is automatically cleared to 0. if a falling edge is detected on the scl pin during formatless operation, i 2 c bus interface operation is deferred until a stop condition is detected.
527 16.3.8 operation using the dtc the i 2 c bus format provides for selection of the slave device and transfer direction by means of the slave address and the r/w bit, confirmation of reception with the acknowledge bit, indication of the last frame, and so on. therefore, continuous data transfer using the dtc must be carried out in conjunction with cpu processing by means of interrupts. table 16.5 shows some examples of processing using the dtc. these examples assume that the number of transfer data bytes is known in slave mode. table 16.5 examples of operation using the dtc item master transmit mode master receive mode slave transmit mode slave receive mode slave address + r/w bit transmission/ reception transmission by dtc (icdr write) transmission by cpu (icdr write) reception by cpu (icdr read) reception by cpu (icdr read) dummy data read processing by cpu (icdr read) actual data transmission/ reception transmission by dtc (icdr write) reception by dtc (icdr read) transmission by dtc (icdr write) reception by dtc (icdr read) dummy data (h'ff) write processing by dtc (icdr write) last frame processing not necessary reception by cpu (icdr read) not necessary reception by cpu (icdr read) transfer request processing after last frame processing 1st time: clearing by cpu 2nd time: end condition issuance by cpu not necessary automatic clearing on detection of end condition during transmission of dummy data (h'ff) not necessary setting of number of dtc transfer data frames transmission: actual data count + 1 (+1 equivalent to slave address + r/w bits) reception: actual data count transmission: actual data count + 1 (+1 equivalent to dummy data (h'ff)) reception: actual data count
528 16.3.9 noise canceler the logic levels at the scl and sda pins are routed through noise cancelers before being latched internally. figure 16.13 shows a block diagram of the noise canceler circuit. the noise canceler consists of two cascaded latches and a match detector. the scl (or sda) input signal is sampled on the system clock, but is not passed forward to the next circuit unless the outputs of both latches agree. if they do not agree, the previous value is held. system clock period sampling clock c dq latch c dq latch scl or sda input signal match detector internal scl or sda signal sampling clock figure 16.13 block diagram of noise canceler
529 16.3.10 sample flowcharts figures 16.14 to 16.17 show sample flowcharts for using the i 2 c bus interface in each mode. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] start initialize read bbsy in iccr no bbsy = 0? yes set mst = 1 and trs = 1 in iccr write bbsy = 1 and scp = 0 in iccr clear iric in iccr read iric in iccr no yes iric = 1? write transmit data in icdr read ackb in icsr ackb = 0? no yes no yes transmit mode? write transmit data in icdr read iric in iccr iric = 1? no yes clear iric in iccr read ackb in icsr end of transmission (ackb = 1)? no yes write bbsy = 0 and scp = 0 in iccr end master receive mode [1] test the status of the scl and sda lines. [2] select master transmit mode. [3] generate a start condition. [4] set transmit data for the first byte (slave address + r/w). [5] wait for 1 byte to be transmitted. [6] test for acknowledgement by the designated slave device. [7] set transmit data for the second and subsequent bytes. [8] wait for 1 byte to be transmitted. [9] test for end of transfer. [10] generate a stop condition. figure 16.14 flowchart for master transmit mode (example)
530 master receive mode set trs = 0 in iccr set ackb = 0 in icsr last receive? read icdr read iric in iccr clear iric in iccr iric = 1? yes no no yes set ackb = 1 in icsr read icdr read iric in iccr iric = 1? clear iric in iccr clear iric in iccr set trs = 1 in iccr read icdr write bbsy = 0 and scp = 0 in iccr end [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] yes no [1] select receive mode. [2] set acknowledge data. [3] start receiving. the first read is a dummy read. [4] wait for 1 byte to be received. [5] set acknowledge data for the last receive. [6] start the last receive. [7] wait for 1 byte to be received. [8] select transmit mode. [9] read the last receive data (if icdr is read without selecting transmit mode, receive operations will resume). [10] generate a stop condition. figure 16.15 flowchart for master receive mode (example)
531 start initialize set mst = 0 and trs = 0 in iccr set ackb = 0 in icsr read iric in iccr iric = 1? yes no clear iric in iccr read aas and adz in icsr aas = 1 and adz = 0? read trs in iccr trs = 0? no yes no yes yes no yes yes no no [1] [2] [3] [4] [5] [6] [7] [8] last receive? read icdr read iric in iccr iric = 1? clear iric in iccr set ackb = 1 in icsr read icdr read iric in iccr read icdr iric = 1? clear iric in iccr end general call address processing * description omitted slave transmit mode [1] select slave receive mode. [2] wait for the first byte to be received (slave address). [3] start receiving. the first read is a dummy read. [4] wait for the transfer to end. [5] set acknowledge data for the last receive. [6] start the last receive. [7] wait for the transfer to end. [8] read the last receive data. figure 16.16 flowchart for slave receive mode (example)
532 slave transmit mode write transmit data in icdr read iric in iccr iric = 1? clear iric in iccr clear iric in iccr clear iric in iccr read ackb in icsr set trs = 0 in iccr end of transmission (ackb = 1)? yes no no yes end [1] [2] [3] read icdr [5] [4] [1] set transmit data for the second and subsequent bytes. [2] wait for 1 byte to be transmitted. [3] test for end of transfer. [4] select slave receive mode. [5] dummy read (to release the scl line). figure 16.17 flowchart for slave transmit mode (example)
533 16.3.11 initialization of internal state the iic has a function for forcible initialization of its internal state if a deadlock occurs during communication. initialization is executed in accordance with the setting of bits clr3 to clr0 in the ddcswr register. for details see section 16.2.8, ddc switch register (ddcswr). scope of initialization: the initialization executed by this function covers the following items: tdre and rdrf internal flags transmit/receive sequencer and internal operating clock counter internal latches for retaining the output state of the scl and sda pins (wait, clock, data output, etc.) the following items are not initialized: actual register values (icdr, sar, sarx, icmr, iccr, icsr, ddcswr, stcr) internal latches used to retain register read information for setting/clearing flags in the icmr, iccr, icsr, and ddcswr registers the value of the icmr register bit counter (bc2 to bc0) generated interrupt sources (interrupt sources transferred to the interrupt controller) notes on initialization: interrupt flags and interrupt sources are not cleared, and so flag clearing measures must be taken as necessary. basically, other register flags are not cleared either, and so flag clearing measures must be taken as necessary. the write data for bits clr3 to clr0 is not retained. to perform iic clearance, bits clr3 to clr0 must be written to simultaneously using an mov instruction. do not use a bit manipulation instruction such as bclr. similarly, when clearing is required again, all the bits must be written to simultaneously in accordance with the setting. if a flag clearing setting is made during transmission/reception, the iic module will stop transmitting/receiving at that point and the scl and sda pins will be released. when transmission/reception is started again, register initialization, etc., must be carried out as necessary to enable correct communication as a system. the value of the bbsy bit cannot be modified directly by this module clear function, but since the stop condition pin waveform is generated according to the state and release timing of the scl and sda pins, the bbsy bit may be cleared as a result. similarly, state switching of other bits and flags may also have an effect.
534 to prevent problems caused by these factors, the following procedure should be used when initializing the iic state. 1. execute initialization of the internal state according to the setting of bits clr3 to clr0. 2. execute a stop condition issuance instruction (write 0 to bbsy and scp) to clear the bbst bit to 0, and wait for two transfer rate clock cycles. 3. re-execute initialization of the internal state according to the setting of bits clr3 to clr0. 4. initialize (re-set) the iic registers. 16.4 usage notes in master mode, if an instruction to generate a start condition is immediately followed by an instruction to generate a stop condition, neither condition will be output correctly. to output consecutive start and stop conditions, after issuing the instruction that generates the start condition, read the relevant ports, check that scl and sda are both low, then issue the instruction that generates the stop condition. note that scl may not yet have gone low when bbsy is cleared to 0. either of the following two conditions will start the next transfer. pay attention to these conditions when reading or writing to icdr. ? write access to icdr when ice = 1 and trs = 1 (including automatic transfer from icdrt to icdrs) ? read access to icdr when ice = 1 and trs = 0 (including automatic transfer from icdrs to icdrr) table 16.6 shows the timing of scl and sda output in synchronization with the internal clock. timings on the bus are determined by the rise and fall times of signals affected by the bus load capacitance, series resistance, and parallel resistance. table 16.6 i 2 c bus timing (scl and sda output) item symbol output timing unit notes scl output cycle time t sclo 28t cyc to 256t cyc ns figure 25.27 scl output high pulse width t sclho 0.5t sclo ns (reference) scl output low pulse width t scllo 0.5t sclo ns sda output bus free time t bufo 0.5t sclo C 1t cyc ns start condition output hold time t staho 0.5t sclo C 1t cyc ns retransmission start condition output setup time t staso 1t sclo ns stop condition output setup time t stoso 0.5t sclo + 2t cyc ns data output setup time (master) t sdaso 1t scllo C 3t cyc ns data output setup time (slave) 1t scll C (6t cyc or 12t cyc * ) data output hold time t sdaho 3t cyc ns note: * 6t cyc when iicx is 0, 12t cyc when 1.
535 scl and sda input is sampled in synchronization with the internal clock. the ac timing therefore depends on the system clock cycle t cyc , as shown in table 25.10 in section 25, electrical characteristics. note that the i 2 c bus interface ac timing specifications will not be met with a system clock frequency of less than 5 mhz. the i 2 c bus interface specification for the scl rise time t sr is under 1000 ns (300 ns for high- speed mode). in master mode, the i 2 c bus interface monitors the scl line and synchronizes one bit at a time during communication. if t sr (the time for scl to go from low to v ih ) exceeds the time determined by the input clock of the i 2 c bus interface, the high period of scl is extended. the scl rise time is determined by the pull-up resistance and load capacitance of the scl line. to insure proper operation at the set transfer rate, adjust the pull-up resistance and load capacitance so that the scl rise time does not exceed the values given in the table below. table 16.7 permissible scl rise time (t sr ) values time indication iicx t cyc indicatio n i 2 c bus specification (max.) ? = 5 mhz ? = 8 mhz ? = 10 mhz ? = 16 mhz ? = 20 mhz 0 7.5t cyc normal mode 1000 ns 1000 ns 937 ns 750 ns 468 ns 375 ns high-speed mode 300 ns 300 ns 300 ns 300 ns 300 ns 300 ns 1 17.5t cyc normal mode 1000 ns 1000 ns 1000 ns 1000 ns 1000 ns 875 ns high-speed mode 300 ns 300 ns 300 ns 300 ns 300 ns 300 ns the i 2 c bus interface specifications for the scl and sda rise and fall times are under 1000 ns and 300 ns. the i 2 c bus interface scl and sda output timing is prescribed by t scyc and t cyc , as shown in table 16.6. however, because of the rise and fall times, the i 2 c bus interface specifications may not be satisfied at the maximum transfer rate. table 16.8 shows output timing calculations for different operating frequencies, including the worst-case influence of rise and fall times. t bufo fails to meet the i 2 c bus interface specifications at any frequency. the solution is either (a) to provide coding to secure the necessary interval (approximately 1 s) between issuance of a stop condition and issuance of a start condition, or (b) to select devices whose input timing permits this output timing for use as slave devices connected to the i 2 c bus. t scllo in high-speed mode and t staso in standard mode fail to satisfy the i 2 c bus interface specifications for worst-case calculations of t sr /t sf . possible solutions that should be investigated include (a) adjusting the rise and fall times by means of a pull-up resistor and capacitive load, (b) reducing the transfer rate to meet the specifications, or (c) selecting devices whose input timing permits this output timing for use as slave devices connected to the i 2 c bus.
536 table 16.8 i 2 c bus timing (with maximum influence of t sr /t sf ) time indication (at maximum transfer rate) [ns] item t cyc indication t sr /t sf influence (max.) i 2 c bus specifi- cation (min.) ? = 5 mhz ? = 8 mhz ? = 10 mhz ? = 16 mhz ? = 20 mhz t sclho 0.5t sclo (Ct sr ) standard mode C1000 4000 4000 4000 4000 4000 4000 high-speed mode C300 600 950 950 950 950 950 t scllo 0.5t sclo (Ct sf ) standard mode C250 4700 4750 4750 4750 4750 4750 high-speed mode C250 1300 1000 * 1 1000 * 1 1000 * 1 1000 * 1 1000 * 1 t bufo 0.5t sclo C1t cyc standard mode C1000 4700 3800 * 1 3875 * 1 3900 * 1 3938 * 1 3950 * 1 ( Ct sr ) high-speed mode C300 1300 750 * 1 825 * 1 850 * 1 888 * 1 900 * 1 t staho 0.5t sclo C1t cyc standard mode C250 4000 4550 4625 4650 4688 4700 (Ct sf ) high-speed mode C250 600 800 875 900 938 950 t staso 1t sclo (Ct sr ) standard mode C1000 4700 9000 9000 9000 9000 9000 high-speed mode C300 600 2200 2200 2200 2200 2200 t stoso 0.5t sclo + 2t cyc standard mode C1000 4000 4400 4250 4200 4125 4100 (Ct sr ) high-speed mode C300 600 1350 1200 1150 1075 1050 t sdaso (master) 1t scllo * 3 C 3t cyc standard mode C1000 250 3100 3325 3400 3513 3550 (Ct sr ) high-speed mode C300 100 400 625 700 813 850 t sdaso (slave) 1t scll * 3 C 12t cyc * 2 standard mode C1000 250 1300 2200 2500 2950 3100 (Ct sr ) high-speed mode C300 100 C1400 * 1 C500 * 1 C200 * 1 250 400
537 table 16.8 i 2 c bus timing (with maximum influence of t sr /t sf ) (cont) time indication (at maximum transfer rate) [ns] item t cyc indication t sr /t sf influence (max.) i 2 c bus specifi- cation (min.) ? = 5 mhz ? = 8 mhz ? = 10 mhz ? = 16 mhz ? = 20 mhz t sdaho 3t cyc standard mode 0 0 600 375 300 188 150 high-speed mode 0 0 600 375 300 188 150 notes: 1. does not meet the i 2 c bus interface specification. remedial action such as the following is necessary: (a) secure a start/stop condition issuance interval; (b) adjust the rise and fall times by means of a pull-up resistor and capacitive load; (c) reduce the transfer rate; (d) select slave devices whose input timing permits this output timing. the values in the above table will vary depending on the settings of the iicx bit and bits cks0 to cks2. depending on the frequency it may not be possible to achieve the maximum transfer rate; therefore, whether or not the i 2 c bus interface specifications are met must be determined in accordance with the actual setting conditions. 2. value when the iicx bit is set to 1. when the iicx bit is cleared to 0, the value is (t scll C 6t cyc ). 3. calculated using the i 2 c bus specification values (standard mode: 4700 ns min.; high- speed mode: 1300 ns min.).
538 note on icdr read at end of master reception to halt reception at the end of a receive operation in master receive mode, set the trs bit to 1 and write 0 to bbsy and scp in iccr. this changes sda from low to high when scl is high, and generates the stop condition. after this, receive data can be read by means of an icdr read, but if data remains in the buffer the icdrs receive data will not be transferred to icdr, and so it will not be possible to read the second byte of data. if it is necessary to read the second byte of data, issue the stop condition in master receive mode (i.e. with the trs bit cleared to 0). when reading the receive data, first confirm that the bbsy bit in the iccr register is cleared to 0, the stop condition has been generated, and the bus has been released, then read the icdr register with trs cleared to 0. note that if the receive data (icdr data) is read in the interval between execution of the instruction for issuance of the stop condition (writing of 0 to bbsy and scp in iccr) and the actual generation of the stop condition, the clock may not be output correctly in subsequent master transmission. clearing of the mst bit after completion of master transmission/reception, or other modifications of iic control bits to change the transmit/receive operating mode or settings, must be carried out during interval (a) in figure 16.18 (after confirming that the bbsy bit has been cleared to 0 in the iccr register). sda scl internal clock bbsy bit master receive mode icdr reading prohibited bit 0 a 8 9 stop condition (a) start condition execution of stop condition issuance instruction (0 written to bbsy and scp) confirmation of stop condition generation (0 read from bbsy) start condition issuance figure 16.18 points for attention concerning reading of master receive data
539 section 17 keyboard buffer controller [h8s/2148 series] provided in the h8s/2148 series; not provided in the h8s/2144 series. 17.1 overview the h8s/2148 series has three on-chip keyboard buffer controller channels, designated 0, 1, and 2. the keyboard buffer controller is provided with functions conforming to the ps/2 interface specifications. data transfer using the keyboard buffer controller employs a data line (kd) and a clock line, providing economical use of connectors, board surface area, etc. figure 17.1 shows how the keyboard buffer controller is connected. 17.1.1 features conforms to ps/2 interface specifications direct bus drive (via the kclk and kd pins) interrupt sources: on completion of data reception and on detection of clock edge error detection: parity error and stop bit monitoring vcc kclk in kclk out kd in kd out keyboard buffer controller (h8s/2148 series chip) system side kclk in kclk out kd in kd out i/f keyboard side vcc clock data figure 17.1 keyboard buffer controller connection
540 17.1.2 block diagram figure 17.2 shows a block diagram of the keyboard buffer controller. kd (ps2ad, ps2bd, ps2cd) kdi kclki kdo kclko parity register counter value kb interrupt kclk (ps2ac, ps2bc, ps2cc) legend: kd: kbc data i/o pin kclk: kbc clock i/o pin kbbr: keyboard data buffer register kbcrh: keyboard control register h kbcrl: keyboard control register l control logic kbbr kbcrh kbcrl bus interface internal data bus module data bus figure 17.2 block diagram of keyboard buffer controller
541 17.1.3 input/output pins table 17.1 lists the input/output pins used by the keyboard buffer controller. table 17.1 keyboard buffer controller input/output pins channel name abbreviation * i/o function 0 kbc clock i/o pin (kclk0) ps2ac i/o kbc clock input/output kbc data i/o pin (kd0) ps2ad i/o kbc data input/output 1 kbc clock i/o pin (kclk1) ps2bc i/o kbc clock input/output kbc data i/o pin (kd1) ps2bd i/o kbc data input/output 2 kbc clock i/o pin (kclk2) ps2cc i/o kbc clock input/output kbc data i/o pin (kd2) ps2cd i/o kbc data input/output note: * these are the external i/o pin names. in the text, clock i/o pins are referred to as kclk and data i/o pins as kd, omitting the channel designations. 17.1.4 register configuration table 17.2 lists the registers of the keyboard buffer controller. table 17.2 keyboard buffer controller registers channel name abbreviation r/w initial value address * 1 0 keyboard control register h kbcrh0 r/(w) * 2 h'70 h'fed8 keyboard control register l kbcrl0 r/w h'70 h'fed9 keyboard data buffer register kbbr0 r h'00 h'feda 1 keyboard control register h kbcrh1 r/(w) * 2 h'70 h'fedc keyboard control register l kbcrl1 r/w h'70 h'fedd keyboard data buffer register kbbr1 r h'00 h'fede 2 keyboard control register h kbcrh2 r/(w) * 2 h'70 h'fee0 keyboard control register l kbcrl2 r/w h'70 h'fee1 keyboard data buffer register kbbr2 r h'00 h'fee2 notes: 1. lower 16 bits of the address. 2. only 0 can be written in bits 2 and 1, to clear the flags.
542 17.2 register descriptions 17.2.1 keyboard control register h (kbcrh) bit 76543210 kbioe kclki kdi kbfsel kbie kbf per kbs initial value 01110000 read/write r/w r r r/w r/w r/(w) * r/(w) * r note: * only 0 can be written, to clear the flags. kbcrh is an 8-bit readable/writable register that indicates the operating status of the keyboard buffer controller. kbcrh is initialized to h'70 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bits 6, 5, and 2 to 0 are also initialized when kbioe is cleared to 0. bit 7keyboard in/out enable (kbioe): selects whether or not the keyboard buffer controller is used. when kbioe is set to 1, the keyboard buffer controller is enabled for transmission and reception and the port pins function as kclk and kd i/o pins. when kbioe is cleared to 0, the keyboard buffer controller stops functioning and the port pins go to the high- impedance state. bit 7 kbioe description 0 the keyboard buffer controller is non-operational (kclk and kd signal pins have port functions) (initial value) 1 the keyboard buffer controller is enabled for transmission and reception (kclk and kd signal pins are in the bus drive state) bit 6keyboard clock in (kclki): monitors the kclk i/o pin. this bit cannot be modified. bit 6 kclki description 0 kclk i/o pin is low 1 kclk i/o pin is high (initial value)
543 bit 5keyboard data in (kdi): monitors the kdi i/o pin. this bit cannot be modified. bit 5 kdi description 0 kd i/o pin is low 1 kd i/o pin is high (initial value) bit 4keyboard buffer register full select (kbfsel): selects whether the kbf bit is used as the keyboard buffer register full flag or as the kclk fall interrupt flag, when kbfsel is cleared to 0, the kbe bit in the kbcrl register should be cleared to 0 to disable reception. bit 4 kbfsel description 0 kbf bit is used as kclk fall interrupt flag 1 kbf bit is used as keyboard buffer register full flag (initial value) bit 3keyboard interrupt enable (kbie): enables or disables interrupts from the keyboard buffer controller to the cpu. bit 3 kbie description 0 interrupt requests are disabled (initial value) 1 interrupt requests are enabled bit 2keyboard buffer register full (kbf): indicates that data reception has been completed and the received data is in the keyboard data buffer register (kbbr). bit 2 kbf description 0 [clearing condition] (initial value) read kbf when kbf =1, then write 0 in kbf 1 [setting condition] when data has been received normally and has been transferred to kbbr (keyboard buffer register full flag) when a kclk falling edge is detected (while kbfsel = 0) (kclk interrupt flag)
544 bit 1parity error (per): indicates that an odd parity error has occurred. bit 1 per description 0 [clearing condition] (initial value) read per when per =1, then write 0 in per 1 [setting condition] when an odd parity error occurs bit 0keyboard stop (kbs): indicates the receive data stop bit. valid only when kbf = 1. bit 0 kbs description 0 0 stop bit received (initial value) 1 1 stop bit received
545 17.2.2 keyboard control register l (kbcrl) bit 76543210 kbe kclko kdo rxcr3 rxcr2 rxcr1 rxcr0 initial value 01110000 read/write r/w r/w r/w rrrr kbcrl is an 8-bit readable/writable register that enables the receive counter count and controls the keyboard buffer controller pin output. kbcrl is initialized to h'70 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7keyboard enable (kbe): enables or disables loading of receive data into the keyboard data buffer register (kbbr). bit 7 kbe description 0 loading of receive data into kbbr is disabled (initial value) 1 loading of receive data into kbbr is enabled bit 6keyboard clock out (kclko): controls kbc clock i/o pin output. bit 6 kclko description 0 keyboard buffer controller clock i/o pin is low 1 keyboard buffer controller clock i/o pin is high (initial value) bit 5keyboard data out (kdo): controls kbc data i/o pin output. bit 5 kdo description 0 keyboard buffer controller data i/o pin is low 1 keyboard buffer controller data i/o pin is high (initial value)
546 bit 4reserved: this bit cannot be modified and is always read as 1. bits 3 to 0receive counter (rxcr3 to rxcr0): these bits indicate the received data bit. their value is incremented on the fall of kclk. these bits cannot be modified. the receive counter is initialized to 0000 by a reset and when 0 is written in kbe. its value returns to 0000 after a stop bit is received. bit 3 bit 2 bit 1 bit 0 rxcr3 rxcr2 rxcr1 rxcr0 receive data contents 0 0 0 0 (initial value) 1 start bit 1 0 kb0 1 kb1 1 0 0 kb2 1 kb3 1 0 kb4 1 kb5 1000kb6 1 kb7 1 0 parity bit 1 1
547 17.2.3 keyboard data buffer register (kbbr) bit 76543210 kb7 kb6 kb5 kb4 kb3 kb2 kb1 kb0 initial value 00000000 read/write rrrrrrrr kbbr is a read-only register that stores receive data. its value is valid only when kbf = 1. kbbr is initialized to h'00 by a reset, in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode, and when kbioe is cleared to 0.
548 17.3 operation 17.3.1 receive operation in a receive operation, both kclk (clock) and kd (data) are outputs on the keyboard side and inputs on the h8s/2148 series chip (system) side. kd receives a start bit, 8 data bits (lsb-first), an odd parity bit, and a stop bit, in that order. the kd value is valid when kclk is low. a sample receive processing flowchart is shown in figure 17.3, and the receive timing in figure 17.4. start set kbioe bit read kbcrh kclki and kdi bits both 1? set kbe bit receive enabled state kbf = 1? per = 0? kbs = 1? read kbbr receive data processing clear kbf flag (receive enabled state) keyboard side in data transmission state. execute receive abort processing. error handling [1] set the kbioe bit to 1 in kbcrl. [2] read kbcrh, and if the kclki and kdi bits are both 1, set the kbe bit (receive enabled state). [3] detect the start bit output on the keyboard side and receive data in synchronization with the fall of kclk. [4] when a stop bit is received, the keyboard buffer controller drives kclk low to disable keyboard transmission (automatic i/o inhibit). if the kbie bit is set to 1 in kbcrh, an interrupt request is sent to the cpu at the same time. [5] perform receive data processing. [6] clear the kbf flag to 0 in kbcrl. at the same time, the system automatically drives kclk high, setting the receive enabled state. the receive operation can be continued by repeating steps [3] to [6]. [1] [2] [3] [4] [5] [6] yes no yes yes yes no no no figure 17.3 sample receive processing flowchart
549 123 kclk (pin state) kd (pin state) kclk (input) kclk (output) kb7 to kb0 per kbs kbf start bit parity bit stop bit receive processing/ error handling automatic i/o inhibit previous data receive data flag cleared 9 10 11 7 01 kb0 kb1 [1] [2] [3] [4] [5] [6] figure 17.4 receive timing
550 17.3.2 transmit operation in a transmit operation, kclk (clock) is an output on the keyboard side, and kd (data) is an output on the h8s/2148 series chip (system) side. kd outputs a start bit, 8 data bits (lsb-first), an odd parity bit, and a stop bit, in that order. the kd value is valid when kclk is high. a sample transmit processing flowchart is shown in figure 17.5, and the transmit timing in figure 17.6. start set kbioe bit kclki = 0? read kbcrh kclki and kdi bits both 1? set i/o inhibit (kclko = 0) kbe = 0 (kbbr reception disabled) kdo remains at 1 wait set start bit (kdo = 0) set i/o inhibit (kclko = 1) kclko remains at 0 kdo remains at 0 i = 0 read kbcrh set transmit data (kdo = d(i)) read kbcrh kclki = 1? i = i + 1 i > 9? read kbcrh kclki = 1? yes no i = 0 to 7: transmit data i = 8: parity bit i = 9: stop bit no yes yes yes yes no no no 1 2 [1] set the kbe bit to 1 in kbcrh, and the kbioe bit to 1 in kbcrl. [2] read kbcrh, and if the kclki and kdi bits are both 1, write 0 in the kclko bit (set i/o inhibit). [3] write 0 in the kbe bit (disable kbbr receive operation). [4] write 0 in the kdo bit (set start bit). [5] write 1 in the kclko bit (clear i/o inhibit). [6] read kbcrh, and when kclki = 0, set the transmit data in the kdo bit (lsb-first). next, set the parity bit and stop bit in the kdo bit. [7] after transmitting the stop bit, read kbcrl and confirm that kdi = 0 (receive completed notification from the keyboard). [8] read kbcrh. confirm that the kclki and kdi bits are both 1. the transmit operation can be continued by repeating steps [2] to [8]. [1] [2] [3] [4] [5] [6] figure 17.5 sample transmit processing flowchart
551 read kbcrh transmit end state (kclk = high, kd = high) yes note: * to switch to reception after transmission, set kbe to 1 (kbbr receive enable) while kclki is low. 1 kclki = 0? no kdi = 0? read kbcrh kclk = 1? yes yes no no error handling to receive operation or transmit operation keyboard side in data transmission state. execute receive abort processing. 2 * [7] [8] figure 17.5 sample transmit processing flowchart (cont) 1 01 01 7 7 2891011 kclk (pin state) kd (pin state) kclk (output) kd (output) kclk (input) kd (input) start bit start bit parity bit stop bit parity bit stop bit i/o inhibit receive completed notification [1] [2] [3] [4] [5] [6] [7] [8] figure 17.6 transmit timing
552 17.3.3 receive abort the h8s/2148 series device (system side) can forcibly abort transmission from the device connected to it (keyboard side) in the event of a protocol error, etc. in this case, the system holds the clock low. during reception, the keyboard also outputs a clock for synchronization, and the clock is monitored when the keyboard output clock is high. if the clock is low at this time, the keyboard judges that there is an abort request from the system, and data transmission from the keyboard is aborted. thus the system can abort reception by holding the clock low for a certain period. a sample receive abort processing flowchart is shown in figure 17.7, and the receive abort timing in figure 17.8.
553 read kbcrl kbf = 0? rxcr3 to rxcr0 3 b'1001? disable receive abort requests yes start receive state read kbcrh processing 1 kclko = 0 (receive abort request) retransmit command transmission (data)? kbe = 0 (disable kbbr reception and clear receive counter) set start bit (kdo = 0) clear i/o inhibit (kclko = 1) transmit data to transmit operation kbe = 0 (disable kbbr reception and clear receive counter) kbe = 1 (enable kb operation) clear i/o inhibit (kclko = 1) to receive operation [1] read kbcrl, and if kbf = 1, perform processing 1. [2] read kbcrh, and if the value of bits rxcr3 to rxcr0 is less than b'1001, write 0 in kclko to abort reception. if the value of bits rxcr3 to rxcr0 is b'1001 or greater, wait until stop bit reception is completed, then perform receive data processing, and proceed to the next operation. [3] if the value of bits rxcr3 to rxcr0 is b'1001 or greater, the parity bit is being received. with the ps2 interface, a receive abort request following parity bit reception is disabled. wait until stop bit reception is completed, perform receive data processing and clear the kbf flag, then proceed to the next operation. yes no no no yes [1] [2] [3] figure 17.7 sample receive abort processing flowchart
554 receive data processing clear kbf flag (kclk = h) processing 1 receive operation ends normally [1] on the system side, drive the kclk pin low, setting the i/o inhibit state. [1] transmit enabled state. if there is transmit data, the data is transmitted. figure 17.7 sample receive abort processing flowchart (cont) keyboard side monitors clock during receive operation (transmit operation as seen from keyboard), and aborts receive operation during this period. kclk (pin state) kd (pin state) kclk (input) kclk (output) kd (input) kd (output) reception in progress receive abort request transmit operation start bit figure 17.8 receive abort and transmit start (transmission/reception switchover) timing
555 17.3.4 kclki and kdi read timing figure 17.9 shows the kclki and kdi read timing. t1 t2 * internal read signal kclk, kd (pin state) kclki, kdi (register) internal data bus (read data) note: * the ?clock shown here is scaled by 1/n in medium-speed mode when the operating mode is active mode. figure 17.9 kclki and kdi read timing 17.3.5 kclko and kdo write timing figure 17.10 shows the klcko and kdo write timing and the kclk and kd pin states. internal write signal * kclko, kdo (register) kclk, kd (pin state) note: * the ?clock shown here is scaled by 1/n in medium-speed mode when the operating mode is active mode. t1 t2 figure 17.10 kclko and kdo write timing
556 17.3.6 kbf setting timing and kclk control figure 17.11 shows the kbf setting timing and the kclk pin states. kclk (pin) * internal kclk falling edge signal rxcr3 to rxcr0 kclk (output) kbf 11th fall automatic i/o inhibit h'000 h'010 note: * the ?clock shown here is scaled by 1/n in medium-speed mode when the operating mode is active mode. figure 17.11 kbf setting and kclk automatic i/o inhibit generation timing
557 17.3.7 receive timing figure 17.12 shows the receive timing. n + 1 n + 2 n kclk (pin) note: * the ?clock shown here is scaled by 1/n in medium-speed mode when the operating mode is active mode. kd (pin) internal kclk (kclki) falling edge signal rxcr3 to rxcr0 internal kd (kdi) kbbr7 to kbbr0 * figure 17.12 receive counter and kbbr data load timing
558 17.3.8 kclk fall interrupt operation in this device, clearing the kbfsel bit to 0 in kbcrh enables the kbf bit in kbcrl to be used as a flag for the interrupt generated by the fall of kclk input. figure 17.13 shows the setting method and an example of operation. start set kbioe kbf = 1 (interrupt generated) kbe = 0 (kbbr reception disabled) interrupt handling clear kbf kclk pin fall detected? kbfsel = 0 kbie = 1 (kclk falling edge interrupts enabled) yes no kclk (pin state) kbf bit interrupt generated interrupt generated cleared by software note: the kbf setting timing is the same as the timing of kbf setting and kclk automatic i/o inhibit bit generation in figure 17.11. when the kbf bit is used as the kclk input fall interrupt flag, the automatic i/o inhibit function does not operate. figure 17.13 example of kclk input fall interrupt operation
559 17.3.9 usage note when kbioe is 0, the internal kclk and internal kd settings are fixed at 1. therefore, if the kclk pin is low when the kbioe bit is set to 1, the edge detection circuit operates and the kclk falling edge is detected. if the kbfsel bit and kbe bit are both 0 at this time, the kbf bit is set. figure 17.14 shows the timing of kbioe setting and kclk falling edge detection. t1 t2 kclk (pin) internal kclk (kclki) falling edge signal kbioe kbfsel kbe kbf figure 17.14 kbioe setting and kclk falling edge detection timing
560
561 section 18 host interface [h8s/2148 series] provided in the h8s/2148 series; not provided in the h8s/2144 series. 18.1 overview the h8s/2148 series has an on-chip host interface (hif) that enables connection to an isa bus, widely used as the internal bus in personal computers. the host interface provides a four-channel parallel interface between the on-chip cpu and a host processor. the host interface is available only when the hi12e bit is set to 1 in syscr2. this mode is called slave mode, because it is designed for a master-slave communication system in which the h8s/2148 series chip is slaved to a host processor. 18.1.1 features the features of the host interface are summarized below. the host interface consists of 8-byte data registers, 4-byte status registers, a 2-byte control register, fast a20 gate logic, and a host interrupt request circuit. communication is carried out via seven control signals from the host processor ( &6 , &6 or (&6 , &6 , &6 , ha0, ,25 , and ,2: ), six output signals to the host processor (ga20, hirq1, hirq11, hirq12, hirq3, and hirq4), and an 8-bit bidirectional command/data bus (hdb7 to hdb0). the &6 , &6 (or (&6 ), &6 and &6 signals select one of the four interface channels.
562 18.1.2 block diagram figure 18.1 shows a block diagram of the host interface. internal interrupt signals ibf2 ibf1 control logic hdb7 to hdb0 idr3 odr3 str3 idr4 odr4 str4 hicr2 module data bus host data bus host interrupt request fast a20 gate control port 4, port 8, port b internal data bus bus interface cs1 cs2 / ecs2 cs3 cs4 ior iow ha0 hirq1 hirq11 hirq12 hirq3 hirq4 ga20 hifsd idr1 odr1 str1 idr2 odr2 str2 hicr ibf4 ibf3 legend: idr1: idr2: odr1: odr2: str1: str2: hicr: input data register 1 input data register 2 output data register 1 output data register 2 status register 1 status register 2 host interface control register 1 idr3: idr4: odr3: odr4: str3: str4: hicr2: input data register 3 input data register 4 output data register 3 output data register 4 status register 3 status register 4 host interface control register 2 figure 18.1 block diagram of host interface
563 18.1.3 input and output pins table 18.1 lists the input and output pins of the host interface module. table 18.1 host interface input/output pins name abbreviation port i/o function i/o read ,25 p93 input host interface read signal i/o write ,2: p94 input host interface write signal chip select 1 &6 p95 input host interface chip select signal for idr1, odr1, str1 chip select 2 * &6 p81 input host interface chip select signal for idr2, (&6 p90 odr2, str2 chip select 3 &6 pb2 input host interface chip select signal for idr3, odr3, str3 chip select 4 &6 pb3 input host interface chip select signal for idr4, odr4, str4 command/data ha0 p80 input host interface address select signal. in host read access, this signal selects the status registers (str1 to str4) or data registers (odr1 to odr4). in host write access to the data registers (idr1 to idr3, and idtr4), this signal indicates whether the host is writing a command or data. data bus hdb7 to hdb0 p37 to p30 i/o host interface data bus host interrupt 1 hirq1 p44 output interrupt output 1 to host host interrupt 11 hirq11 p43 output interrupt output 11 to host host interrupt 12 hirq12 p45 output interrupt output 12 to host host interrupt 3 hirq3 pb0 output interrupt output 3 to host host interrupt 4 hirq4 pb1 output interrupt output 4 to host gate a20 ga20 p81 output a20 gate control signal output hif shutdown hifsd p82 input host interface shutdown control signal note: * selection of &6 or (&6 is by means of the cs2e bit in stcr and the fga20e bit in hicr. host interface channel 2 and the &6 pin can be used when cs2e = 1. when cs2e = 1, &6 is used when fga20e =0, and (&6 is used when fga20e = 1. in this manual, both are referred to as &6 .
564 18.1.4 register configuration table 18.2 lists the host interface registers. host interface registers hicr, idr1, idr2, odr1, odr2, str1, and str2 can only be accessed when the hie bit is set to 1 in syscr. table 18.2 host interface registers abbrevia- r/w initial slave master address * 4 name tion slave host value address * 3 &6 &6 &6 &6 &6 &6 &6 &6 ha0 system control register syscr r/w * 1 h'09 h'ffc4 system control register 2 syscr2 r/w h'00 h'ff83 host interface control register 1 hicr r/w h'f8 h'fff0 host interface control register 2 hicr2 r/w h'f8 h'fe80 input data register 1 idr1 r w h'fff4 0 1 11 0/1 * 5 output data register 1 odr1 r/w r h'fff5 01110 status register 1 str1 r/(w) * 2 r h'00 h'fff6 01111 input data register 2 idr2 r w h'fffc 10110/1 * 5 output data register 2 odr2 r/w r h'fffd 10110 status register 2 str2 r/(w )* 2 r h'00 h'fffe 10111 input data register 3 idr3 r w h'fe84 11010/1 * 5 output data register 3 odr3 r/w r h'fe85 11010 status register 3 str3 r/(w) * 2 r h'00 h'fe86 11011 input data register 4 idr4 r w h'fe8c 11100/1 * 5 output data register 4 odr4 r/w r h'fe8d 11100 status register 4 str4 r/(w) * 2 r h'00 h'fe8e 11101 module stop control mstpcrh r/w h'3f h'ff86 register mstpcrl r/w h'ff h'ff87 notes: 1. bits 5 and 3 are read-only bits. 2. the user-defined bits (bits 7 to 4 and 2) are read/write accessible from the slave processor. 3. address when accessed from the slave processor. the lower 16 bits of the address are shown. 4. pin inputs used in access from the host processor. 5. the ha0 input discriminates between writing of commands and data.
565 18.2 register descriptions 18.2.1 system control register (syscr) bit initial value read/write 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w syscr is an 8-bit readable/writable register which controls h8s/2148 series chip operations. of the host interface registers, hicr, idr1, odr1, str1, idr2, odr2, and str2 can only be accessed when the hie bit is set to 1. hicr2, idr3, odr3, str3, idr4, odr4, and str4 can be accessed regardless of the setting of the hie bit. the host interface &6 and (&6 pins are controlled by the cs2e bit in syscr and the fga20e bit in hicr. see section 3.2.2, system control register (syscr), and section 5.2.1, system control register (syscr), for information on other syscr bits. syscr is initialized to h'09 by a reset and in hardware standby mode. bit 7cs2 enable bit (cs2e): used together with the fga20e bit in hicr to select the pin that performs the &6 function. syscr bit 7 hicr bit 0 cs2e fga20e description 00 &6 pin function halted ( &6 fixed high internally) (initial value) 1 10 &6 pin function selected for p81/ &6 pin 1 &6 pin function selected for p90/ (&6 pin bit 1host interface enable (hie): enables or disables cpu access to the host interface registers. when enabled, the host interface registers (hicr, idr1, odr1, str1, idr2, odr2, and str2) can be accessed. bit 1 hie description 0 host interface register (hicr, idr1, odr1, str1, idr2, odr2, str2), cpu access is disabled (initial value) 1 host interface register (hicr, idr1, odr1, str1, idr2, odr2, str2), cpu access is enabled
566 18.2.2 system control register 2 (syscr2) bit 76543210 kwul1 kwul0 p6pue sde cs4e cs3e hi12e initial value 00000000 read/write r/w r/w r/w r/w r/w r/w r/w syscr2 is an 8-bit readable/writable register which controls chip operations. host interface functions are enabled or disabled by the hi12e bit in syscr2. the number of channels that can be used can be extended to a maximum of four by means of the cs3e bit and cs4e bit. syscr2 is initialized to h'00 by a reset and in hardware standby mode. bits 7 and 6key wakeup level 1 and 0 (kwul1, kwul0): the port 6 input level can be set and changed by software. for details see section 8, i/o ports. bit 5port 6 input pull-up extra (p6pue): controls and selects the current specification for the port 6 mos input pull-up function connected by means of kmpcr settings. for details see section 8, i/o ports. bit 4reserved: do not write 1 to this bit. bit 3shutdown enable (sde): enables or disables the host interface pin shutdown function. when this function is enabled, host interface pin functions can be halted, and the pins placed in the high-impedance state, according to the state of the hifsd pin. bit 3 sde description 0 host interface pin shutdown function disabled (initial value) 1 host interface pin shutdown function enabled
567 bit 2cs4 enable (cs4e): enables or disables host interface channel 4 functions in slave mode. when these functions are enabled, channel 4 pins are enabled and processing can be performed for data transfer between the slave and the host. bit 2 cs4e description 0 host interface pin channel 4 functions disabled (initial value) 1 host interface pin channel 4 functions enabled bit 1cs3 enable (cs3e): enables or disables host interface channel 3 functions in slave mode. when these functions are enabled, channel 3 pins are enabled and processing can be performed for data transfer between the slave and the host. bit 1 cs3e description 0 host interface pin channel 3 functions disabled (initial value) 1 host interface pin channel 3 functions enabled bit 0host interface enable bit (hi12e): enables or disables host interface functions in single-chip mode. when the host interface functions are enabled, slave mode is entered and processing is performed for data transfer between the slave and host. bit 0 hi12e description 0 host interface functions are disabled (initial value) 1 host interface functions are enabled
568 18.2.3 host interface control register (hicr) hicr bit initial value slave read/write host read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 fga20e 0 r/w ? 2 ibfie2 0 r/w ? 1 ibfie1 0 r/w ? hicr2 bit initial value slave read/write host read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 ? 0 ? ? 2 ibfie4 0 r/w ? 1 ibfie3 0 r/w ? hicr is an 8-bit readable/writable register which controls host interface channel 1 and 2 interrupts and the fast a20 gate function. hicr2 is an 8-bit readable/writable register which controls host interface channel 3 and 4 interrupts. hicr and hicr2 are initialized to h'f8 by a reset and in hardware standby mode. bits 7 to 3reserved: these bits cannot be modified and are always read as 1.
569 hicr bits 2 and 1input data register full interrupt enable 2 and 1 (ibfie2, ibfie1) hicr2 bits 2 and 1input data register full interrupt enable 4 and 3 (ibfie4, ibfie3) these bits enable or disable the ibf1, ibf2, ibf3, and ibf4 interrupts to the internal cpu. hicr2 bit 2 hicr2 bit 1 hicr bit 2 hicr bit 1 ibfie4 ibfie3 ibfie2 ibfie1 description 0 input data register (idr1) reception completed interrupt request disabled (initial value) 1 input data register (idr1) reception completed interrupt request enabled 0 input data register (idr2) reception completed interrupt request disabled (initial value) 1 input data register (idr2) reception completed interrupt request enabled 0 input data register (idr3) reception completed interrupt request disabled (initial value) 1 input data register (idr3) reception completed interrupt request enabled 0 input data register (idr4) reception completed interrupt request disabled (initial value) 1 input data register (idr4) reception completed interrupt request enabled hicr bit 0fast a20 gate function enable (fga20e): enables or disables the fast a20 gate function. when the fast a20 gate is disabled, the normal a20 gate can be implemented byte firmware operation of the p81 output. hicr bit 0 fga20e description 0 fast a20 gate function disabled (initial value) 1 fast a20 gate function enabled hicr2 bit 0reserved
570 18.2.4 input data register 1 (idr1) bit initial value slave read/write host read/write 7 idr7 ? r w 6 idr6 ? r w 5 idr5 ? r w 4 idr4 ? r w 3 idr3 ? r w 0 idr0 ? r w 2 idr2 ? r w 1 idr1 ? r w idr1 is an 8-bit read-only register to the slave processor, and an 8-bit write-only register to the host processor. when &6q (n = 1 to 4) is low, information on the host data bus is written into idrn at the rising edge of ,2: . the ha0 state is also latched into the c/ ' bit in strn to indicate whether the written information is a command or data. the initial values of idr1 after a reset and in standby mode are undetermined. 18.2.5 output data register 1 (odr) bit initial value slave read/write host read/write 7 odr7 ? r/w r 6 odr6 ? r/w r 5 odr5 ? r/w r 4 odr4 ? r/w r 3 odr3 ? r/w r 0 odr0 ? r/w r 2 odr2 ? r/w r 1 odr1 ? r/w r odr1 is an 8-bit readable/writable register to the slave processor, and an 8-bit read-only register to the host processor. the odrn contents are output on the host data bus when ha0 is low, &6q (n = 1 to 4) is low, and ,25 is low. the initial values of odr1 after a reset and in standby mode are undetermined.
571 18.2.6 status register (str) bit initial value slave read/write host read/write note: * only 0 can be written, to clear the flag. 7 dbu 0 r/w r 6 dbu 0 r/w r 5 dbu 0 r/w r 4 dbu 0 r/w r 3 c/ d 0 r r 0 obf 0 r/(w) * r 2 dbu 0 r/w r 1 ibf 0 r r strn (n = 1 to 4) is an 8-bit register that indicates status information during host interface processing. bits 3, 1, and 0 are read-only bits to both the host and slave processors. str is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 4 and bit 2defined by user (dbu): the user can use these bits as necessary. bit 3command/data (c/ ' ' ): receives the ha0 input when the host processor writes to idr1, and indicates whether idr1 contains data or a command. bit 3 c/ ' ' description 0 contents of input data register (idr1) are data (initial value) 1 contents of input data register (idr1) are a command bit 1input buffer full (ibf): set to 1 when the host processor writes to idr1. this bit is an internal interrupt source to the slave processor. ibf is cleared to 0 when the slave processor reads idr1. the ibf flag setting and clearing conditions are different when the fast a20 gate is used. for details see table 18.8, fast a20 gate output signals. bit 1 ibf description 0 [clearing condition] when the slave processor reads idr (initial value) 1 [setting condition] when the host processor writes to idr
572 bit 0output buffer full (obf): set to 1 when the slave processor writes to odr1. cleared to 0 when the host processor reads odr. bit 0 obf description 0 [clearing condition] when the host processor reads odr or the slave writes 0 in the obf bit (initial value) 1 [setting condition] when the slave processor writes to odr table 18.3 shows the conditions for setting and clearing the str flags. table 18.3 set/clear timing for str flags flag setting condition clearing condition c/ ' rising edge of hosts write signal ( ,2: ) when ha0 is high rising edge of hosts write signal ( ,2: ) when ha0 is low ibf * rising edge of hosts write signal ( ,2: ) when writing to idr1 falling edge of slaves internal read signal ( 5' ) when reading idr1 obf falling edge of slaves internal write signal ( :5 ) when writing to odr1 rising edge of hosts read signal ( ,25 ) when reading odr1 note: * the ibf flag setting and clearing conditions are different when the fast a20 gate is used. for details see table 18.8, fast a20 gate output signals.
573 18.2.7 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp2 bit is set to 1, the host interface halts and enters module stop mode. see section 24.5, module stop mode, for details. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrl bit 2module stop (mstp2): specifies host interface module stop mode. mstpcrl bit 2 mstp2 description 0 host interface module stop mode is cleared 1 host interface module stop mode is set (initial value)
574 18.3 operation 18.3.1 host interface activation the hif (slave mode) is activated by setting the hi12e bit (bit 0) in syscr2 to 1 in single-chip mode. when the hif (slave mode) is activated, all related i/o ports (data port 3, control ports 8 and 9, and host interrupt request port 4) become dedicated host interface ports. setting the cs3e bit and cs4e bit to 1 enables the number of hif channels to be extended to a four, and makes the channel 3 and 4 related i/o port (part of port b for control and host interrupt requests) a dedicated host interface port. table 18.5 shows hif host interface channel selection and pin operation. table 18.5 host interface channel selection and pin operation hi12e cs2e cs3e cs4e operation 0 host interface functions halted 1000 host interface channel 1 only operating operation of channels 2 to 4 halted (no operation as &6 or (&6 , &6 , and &6 inputs. pins p43, p81, p90, and pb0 to pb3 operate as i/o ports.) 1 host interface channel 1 and 4 functions operating operation of channels 2 and 3 halted (no operation as &6 or (&6 and &6 inputs. pins p43, p81, p90, pb0, and pb2 operate as i/o ports.) 1 0 host interface channel 1 and 3 functions operating operation of channels 2 and 4 halted (no operation as &6 or (&6 and &6 inputs. pins p43, p81, p90, pb1, and pb3 operate as i/o ports.) 1 host interface channel 1, 3, and 4 functions operating operation of channel 2 halted (no operation as &6 or (&6 input. pins p43, p81, and p90 operate as i/o ports.) 1 0 0 host interface channel 1 and 2 functions operating operation of channels 3 and 4 halted (no operation as &6 and &6 inputs. pins pb0 to pb3 operate as i/o ports.) 1 host interface channel 1, 2, and 4 functions operating operation of channel 3 halted (no operation as &6 input. pins pb0 and pb2 operate as i/o ports.) 1 0 host interface channel 1 to 3 functions operating operation of channel 4 halted (no operation as &6 input. pins pb1 and pb3 operate as i/o ports.) 1 host interface channel 1 to 4 functions operating
575 for host read/write timing, see section 25.3.4, on-chip supporting module timing. 18.3.2 control states table 18.6 shows host interface operations from the hif host, and slave operation. table 18.6 host interface operations from hif host, and slave operation other than &6q &6q &6q &6q ,25 ,25 ,2: ,2: ha0 operation 1 0000 setting prohibited 1 setting prohibited 1 0 data read from output data register n (odrn) 1 status read from status register n (strn) 1 0 0 data written to input data register n (idrn) 1 command written to input data register n (idrn) 1 0 idle state 1 idle state (n = 1 to 4)
576 18.3.3 a20 gate the a20 gate signal can mask address a20 to emulate an addressing mode used by personal computers with an 8086*-family cpu. in slave mode, a regular-speed a20 gate signal can be output under firmware control. fast a20 gate output is enabled by setting the fga20e bit (bit 0) to 1 in hicr (h'fff0). note: * intel microprocessor. regular a20 gate operation: output of the a20 gate signal can be controlled by an h'd1 command followed by data. when the slave processor receives data, it normally uses an interrupt routine activated by the ibf1 interrupt to read idr1. if the data follows an h'd1 command, software copies bit 1 of the data and outputs it at the gate a20 pin. fast a20 gate operation: when the fga20e bit is set to 1, p81/ga20 is used for output of a fast a20 gate signal. bit p81ddr must be set to 1 to assign this pin for output. the initial output from this pin will be a logic 1, which is the initial value. afterward, the host processor can manipulate the output from this pin by sending commands and data. this function is available only when register idr1 is accessed using &6 . slave logic decodes the commands input from the host processor. when an h'd1 host command is detected, bit 1 of the data following the host command is output from the ga20 output pin. this operation does not depend on firmware or interrupts, and is faster than the regular processing using interrupts. table 18.7 lists the conditions that set and clear ga20 (p81). figure 18.2 shows the ga20 output in flowchart form. table 18.8 indicates the ga20 output signal values. table 18.7 ga20 (p81) set/clear timing pin name setting condition clearing condition ga20 (p81) rising edge of the hosts write signal ( ,2: ) when bit 1 of the written data is 1 and the data follows an h'd1 host command rising edge of the hosts write signal ( ,2: ) when bit 1 of the written data is 0 and the data follows an h'd1 host command also, when bit fga20e in hicr is cleared to 0
577 start host write h'd1 command received? wait for next byte host write yes data byte? write bit 1 of data byte to dr bit of p81/ga20 yes no no figure 18.2 ga20 output
578 table 18.8 fast a20 gate output signal ha0 data/command internal cpu interrupt flag ga20 (p81) remarks 1 0 1 h'd1 command 1 data * 1 h'ff command 0 0 0 q 1 q (1) turn-on sequence 1 0 1 h'd1 command 0 data * 2 h'ff command 0 0 0 q 0 q (0) turn-off sequence 1 0 1/0 h'd1 command 1 data * 1 command other than h'ff and h'd1 0 0 1 q 1 q (1) turn-on sequence (abbreviated form) 1 0 1/0 h'd1 command 0 data * 2 command other than h'ff and h'd1 0 0 1 q 0 q (0) turn-off sequence (abbreviated form) 1 1 h'd1 command command other than h'd1 0 1 q q cancelled sequence 1 1 h'd1 command h'd1 command 0 0 q q retriggered sequence 1 0 1 h'd1 command any data h'd1 command 0 0 0 q 1/0 q(1/0) consecutively executed sequences notes: 1. arbitrary data with bit 1 set to 1. 2. arbitrary data with bit 1 cleared to 0. 18.3.4 host interface pin shutdown function host interface output can be placed in the high-impedance state according to the state of the hifsd pin. setting the sde bit to 1 in the syscr2 register enables the hifsd pin is slave mode. the hif constantly monitors the hifsd pin, and when this pin goes low, places the host interface output pins (hirq1, hirq11, hirq12, hirq3, hirq4, and ga20) in the high- impedance state. at the same time, the host interface input pins ( &6 , &6 or (&6 , &6 , &6 , ,2: , ,25 , and ha0) are disabled (fixed at the high input state internally) regardless of the pin states, and the signals of the multiplexed functions of these pins (input block) are similarly fixed internally. as a result, the host interface i/o pins (hdb7 to hdb0) also go to the high- impedance state. this state is maintained while the hifsd pin is low, and when the hifsd pin returns to the high-level state, the pins are restored to their normal operation as host interface pins. table 18.9 shows the scope of hif pin shutdown in slave mode.
579 table 18.9 scope of hif pin shutdown in slave mode abbreviation port scope of shutdown in slave mode i/o selection conditions ,25 p93 o input slave mode ,2: p94 o input slave mode &6 p95 o input slave mode &6 p81 d input slave mode and cs2e = 1 and fga20e = 0 (&6 p90 d input slave mode and cs2e = 1 and fga20e = 1 &6 pb2 d input slave mode and cs3e = 1 &6 pb3 d input slave mode and cs4e = 1 ha0 p80 o input slave mode hdb7 to hdb0 p37 to p30 o i/o slave mode hirq11 p43 d output slave mode and cs2e = 1 and p43ddr = 1 hirq1 p44 d output slave mode and p44ddr = 1 hirq12 p45 d output slave mode and p45ddr = 1 hirq3 pb0 d output slave mode and cs3e = 1 and pb0ddr = 1 hirq4 pb1 d output slave mode and cs4e = 1 and pb1ddr = 1 ga20 p81 d output slave mode and fga20e = 1 hifsd p82 input slave mode and sde = 1 notes: slave mode: single-chip mode and hi12e = 1 o: pins shut down by shutdown function the ,54 / $'75* input signal is also fixed in the case of p90 shutdown, the tmci1/hsynci signal in the case of p43 shutdown, and the tmri/csynci in the case of p45 shutdown. d : pins shut down only when the hif function is selected by means of a register setting : pin not shut down
580 18.4 interrupts 18.4.1 ibf1, ibf2, ibf3, ibf4 the host interface can issue two interrupt requests to the slave cpu: ibf1, ibf2, ibf3 and ibf4. they are input buffer full interrupts for input data registers idr1, idr2, idr3 and idr4 respectively. each interrupt is enabled when the corresponding enable bit is set. table 18.8 input buffer full interrupts interrupt description ibf1 requested when ibfie1 is set to 1 and idr1 is full ibf2 requested when ibfie2 is set to 1 and idr2 is full ibf3 requested when ibfie3 is set to 1 and idr3 is full ibf4 requested when ibfie4 is set to 1 and idr4 is full 18.4.2 hirq11, hirq1, hirq12, hirq3, and hirq4 in slave mode (single-chip mode, with hi12e = 1 in syscr2), bits p45dr to p43dr in the port 4 data register (p4dr) and bits pb1odr and pb0odr in the port b data register (pbodr) can be used as host interrupt request latches the corresponding bits in p4dr are cleared to 0 by the host processors read signal ( ,25 ). if &6 and ha0 are low, when ,25 goes low and the host reads odr1, hirq1 and hirq12 are cleared to 0. if &6 and ha0 are low, when ,25 goes low and the host reads odr2, hirq11 is cleared to 0. the corresponding bit in pbodr is cleared to 0 by the hosts read signal ( ,25 ). if &6 and ha0 are low, when ,25 goes low and the host reads odr3, hirq3 is cleared to 0. if &6 and ha0 are low, when ,25 goes low and the host reads odr4, hirq4 is cleared to 0. to generate a host interrupt request, normally on-chip firmware writes 1 in the corresponding bit. in processing the interrupt, the hosts interrupt handling routine reads the output data register (odr1, odr2, odr3, or odr4) and this clears the host interrupt latch to 0. table 18.11 indicates how these bits are set and cleared. figure 18.3 shows the processing in flowchart form.
581 table 18.11 hirq setting/clearing conditions host interrupt signal setting condition clearing condition hirq11 (p43) internal cpu reads 0 from bit p43dr, then writes 1 internal cpu writes 0 in bit p43dr, or host reads output data register 2 hirq1 (p44) internal cpu reads 0 from bit p44dr, then writes 1 internal cpu writes 0 in bit p44dr, or host reads output data register 1 hirq12 (p45) internal cpu reads 0 from bit p45dr, then writes 1 internal cpu writes 0 in bit p45dr, or host reads output data register 1 hirq3 (pb0) internal cpu reads 0 from bit pb0odr, then writes 1 internal cpu writes 0 in bit pb0odr, or host reads output data register 3 hirq4 (pb1) internal cpu reads 0 from bit pb1odr, then writes 1 internal cpu writes 0 in bit pb1odr, or host reads output data register 4 slave cpu master cpu write to odr write 1 to p4dr p4dr = 0? yes no no yes all bytes transferred? hirq output high hirq output low interrupt initiation odr read hardware operations software operations figure 18.3 hirq output flowchart (example of channels 1 and 2) hirq setting/clearing contention: if there is contention between a p4dr or pbodr read/write by the cpu and p4dr (hirq11, hirq1, hirq12) or pbodr (hirq3, hirq4) clearing by the host, clearing by the host is held pending during the p4dr or pbodr read/write by the cpu. p4dr or pbodr clearing is executed after completion of the read/write.
582 18.5 usage note the host interface provides buffering of asynchronous data from the host and slave processors, but an interface protocol must be followed to implement necessary functions and avoid data contention. for example, if the host and slave processors try to access the same input or output data register simultaneously, the data will be corrupted. interrupts can be used to design a simple and effective protocol. also, if two or more of pins &6 to &6 are driven low simultaneously in attempting idr or odr access, signal contention will occur within the chip, and a through-current may result. this usage must therefore be avoided.
583 section 19 d/a converter 19.1 overview the h8s/2148 series and h8s/2144 series have an on-chip d/a converter module with two channels. 19.1.1 features features of the d/a converter module are listed below. eight-bit resolution two-channel output maximum conversion time: 10 s (with 20-pf load capacitance) output voltage: 0 v to av ref d/a output retention in software standby mode
584 19.1.2 block diagram figure 19.1 shows a block diagram of the d/a converter. bus interface module data bus internal data bus 8-bit d/a dadr0 dadr1 dacr control circuit avref avcc da0 da1 avss legend: dacr: dadr0: dadr1: d/a control register d/a data register 0 d/a data register 1 figure 19.1 block diagram of d/a converter
585 19.1.3 input and output pins table 19.1 lists the input and output pins used by the d/a converter module. table 19.1 input and output pins of d/a converter module name abbreviation i/o function analog supply voltage avcc input power supply for analog circuits analog ground avss input ground and reference voltage for analog circuits analog output 0 da0 output analog output channel 0 analog output 1 da1 output analog output channel 1 reference voltage pin avref input reference voltage for analog circuits 19.1.4 register configuration table 19.2 lists the registers of the d/a converter module. table 19.2 d/a converter registers name abbreviation r/w initial value address * d/a data register 0 dadr0 r/w h'00 h'fff8 d/a data register 1 dadr1 r/w h'00 h'fff9 d/a control register dacr r/w h'1f h'fffa module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 note: * lower 16 bits of the address.
586 19.2 register descriptions 19.2.1 d/a data registers 0 and 1 (dadr0, dadr1) bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w d/a data registers 0 and 1 (dadr0 and dadr1) are 8-bit readable/writable registers that store data to be converted. when analog output is enabled, the value in the d/a data register is converted and output continuously at the analog output pin. the d/a data registers are initialized to h'00 by a reset and in hardware standby mode. 19.2.2 d/a control register (dacr) bit initial value read/write 7 daoe1 0 r/w 6 daoe0 0 r/w 5 dae 0 r/w 4 ? 1 3 ? 1 0 ? 1 2 ? 1 1 ? 1 dacr is an 8-bit readable/writable register that controls the operation of the d/a converter module. dacr is initialized to h'1f by a reset and in hardware standby mode. bit 7d/a output enable 1 (daoe1): controls d/a conversion and analog output. bit 7 daoe1 description 0 analog output da1 is disabled (initial value) 1 d/a conversion is enabled on channel 1. analog output da1 is enabled
587 bit 6d/a output enable 0 (daoe0): controls d/a conversion and analog output. bit 6 daoe0 description 0 analog output da0 is disabled (initial value) 1 d/a conversion is enabled on channel 0. analog output da0 is enabled bit 5d/a enable (dae): controls d/a conversion, in combination with bits daoe0 and daoe1. d/a conversion is controlled independently on channels 0 and 1 when dae = 0. channels 0 and 1 are controlled together when dae = 1. output of the converted results is always controlled independently by daoe0 and daoe1. bit 7 bit 6 bit 5 daoe1 daoe0 dae d/a conversion 00 * disabled on channels 0 and 1 1 0 enabled on channel 0 disabled on channel 1 1 enabled on channels 0 and 1 1 0 0 disabled on channel 0 enabled on channel 1 1 enabled on channels 0 and 1 1 * enabled on channels 0 and 1 * : dont care if the h8s/2148 series chip enters software standby mode while d/a conversion is enabled, the d/a output is retained and the analog power supply current is the same as during d/a conversion. if it is necessary to reduce the analog power supply current in software standby mode, disable d/a output by clearing the daoe0, daoe1 and dae bits to 0. bits 4 to 0reserved: these bits cannot be modified and are always read as 1.
588 19.2.3 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp10 bit is set to 1, the d/a converter halts and enters module stop mode at the end of the bus cycle. see section 24.5, module stop mode, for details. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 2module stop (mstp10): specifies d/a converter module stop mode. mstpcrh bit 2 mstp10 description 0 d/a converter module stop mode is cleared 1 d/a converter module stop mode is set (initial value)
589 19.3 operation the d/a converter module has two built-in d/a converter circuits that can operate independently. d/a conversion is performed continuously whenever enabled by the d/a control register (dacr). when a new value is written in dadr0 or dadr1, conversion of the new value begins immediately. the converted result is output by setting the daoe0 or daoe1 bit to 1. an example of conversion on channel 0 is given next. figure 19.2 shows the timing. software writes the data to be converted in dadr0. d/a conversion begins when the daoe0 bit in dacr is set to 1. after the elapse of the conversion time, analog output appears at the da0 pin. the output value is avref (dadr value)/256. this output continues until a new value is written in dadr0 or the daoe0 bit is cleared to 0. if a new value is written in dadr0, conversion begins immediately. output of the converted result begins after the conversion time. when the daoe0 bit is cleared to 0, da0 becomes an input pin. dadr0 write cycle dacr write cycle dadr0 write cycle dacr write cycle address dadr0 daoe0 da0 conversion data (1) conversion data (2) high-impedance state conversion result (1) conversion result (2) t dconv t dconv t : d/a conversion time dconv figure 19.2 d/a conversion (example)
590
591 section 20 a/d converter 20.1 overview the h8s/2148 series and h8s/2144 series incorporate a 10-bit successive-approximations a/d converter that allows up to eight analog input channels to be selected. in addition to the eight analog input channels, up to 16 channels of digital input can be selected for a/d conversion. since the conversion precision falls when digital input is selected, digital input is ideal for use by a comparator identifying multi-valued inputs, for example. 20.1.1 features a/d converter features are listed below. 10-bit resolution eight (analog) or 16 (digital) input channels settable analog conversion voltage range ? the analog conversion voltage range is set using the reference power supply voltage pin (avref) as the analog reference voltage high-speed conversion ? minimum conversion time: 6.7 s per channel (at 20 mhz operation) choice of single mode or scan mode ? single mode: single-channel a/d conversion ? scan mode: continuous a/d conversion on 1 to 4 channels four data registers ? conversion results are held in a 16-bit data register for each channel sample and hold function three kinds of conversion start ? choice of software or timer conversion start trigger (8-bit timer), or $'75* pin a/d conversion end interrupt generation ? an a/d conversion end interrupt (adi) request can be generated at the end of a/d conversion
592 20.1.2 block diagram figure 20.1 shows a block diagram of the a/d converter. module data bus control circuit internal data bus 10-bit d/a comparator + sample-and- hold circuit ?8 ?16 adi interrupt signal bus interface adcsr adcr addrd addrc addrb addra avcc avref avss an0 an1 an2 an3 an4 an5 an6/cin0 to cin7 an7/cin8 to cin15 adtrg conversion start trigger from 8-bit timer successive approximations register multiplexer legend: adcr: a/d control register adcsr: a/d control/status register addra: a/d data register a addrb: a/d data register b addrc: a/d data register c addrd: a/d data register d figure 20.1 block diagram of a/d converter
593 20.1.3 pin configuration table 20.1 summarizes the input pins used by the a/d converter. the avcc and avss pins are the power supply pins for the analog block in the a/d converter. table 20.1 a/d converter pins pin name symbol i/o function analog power supply pin avcc input analog block power supply analog ground pin avss input analog block ground and a/d conversion reference voltage reference power supply pin avref input a/d conversion reference voltage analog input pin 0 an0 input analog input channel 0 analog input pin 1 an1 input analog input channel 1 analog input pin 2 an2 input analog input channel 2 analog input pin 3 an3 input analog input channel 3 analog input pin 4 an4 input analog input channel 4 analog input pin 5 an5 input analog input channel 5 analog input pin 6 an6 input analog input channel 6 analog input pin 7 an7 input analog input channel 7 a/d external trigger input pin $'75* input external trigger input for starting a/d conversion expansion a/d input pins 0 to 15 cin0 to cin15 input expansion a/d conversion input (digital input pin) channels 0 to 15
594 20.1.4 register configuration table 20.2 summarizes the registers of the a/d converter. table 20.2 a/d converter registers name abbreviation r/w initial value address * 1 a/d data register ah addrah r h'00 h'ffe0 a/d data register al addral r h'00 h'ffe1 a/d data register bh addrbh r h'00 h'ffe2 a/d data register bl addrbl r h'00 h'ffe3 a/d data register ch addrch r h'00 h'ffe4 a/d data register cl addrcl r h'00 h'ffe5 a/d data register dh addrdh r h'00 h'ffe6 a/d data register dl addrdl r h'00 h'ffe7 a/d control/status register adcsr r/(w) * 2 h'00 h'ffe8 a/d control register adcr r/w h'3f h'ffe9 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 keyboard comparator control register kbcomp r/w h'00 h'fee4 notes: 1. lower 16 bits of the address. 2. only 0 can be written in bit 7, to clear the flag.
595 20.2 register descriptions 20.2.1 a/d data registers a to d (addra to addrd) 15 ad9 0 r bit initial value read/write 14 ad8 0 r 13 ad7 0 r 12 ad6 0 r 11 ad5 0 r 10 ad4 0 r 9 ad3 0 r 8 ad2 0 r 7 ad1 0 r 6 ad0 0 r 5 ? 0 r 4 ? 0 r 3 ? 0 r 2 ? 0 r 1 ? 0 r 0 ? 0 r there are four 16-bit read-only addr registers, addra to addrd, used to store the results of a/d conversion. the 10-bit data resulting from a/d conversion is transferred to the addr register for the selected channel and stored there. the upper 8 bits of the converted data are transferred to the upper byte (bits 15 to 8) of addr, and the lower 2 bits are transferred to the lower byte (bits 7 and 6) and stored. bits 5 to 0 are always read as 0. the correspondence between the analog input channels and addr registers is shown in table 20.3. the addr registers can always be read by the cpu. the upper byte can be read directly, but for the lower byte, data transfer is performed via a temporary register (temp). for details, see section 20.3, interface to bus master. the addr registers are initialized to h'0000 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. table 20.3 analog input channels and corresponding addr registers analog input channel group 0 group 1 a/d data register an0 an4 addra an1 an5 addrb an2 an6 or cin0 to cin7 addrc an3 an7 or cin8 to cin15 addrd
596 20.2.2 a/d control/status register (adcsr) 7 adf 0 r/(w) * 6 adie 0 r/w 5 adst 0 r/w 4 scan 0 r/w 3 cks 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w bit initial value read/write note: * only 0 can be written in bit 7, to clear the flag. adcsr is an 8-bit readable/writable register that controls a/d conversion operations. adcsr is initialized to h'00 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7a/d end flag (adf): status flag that indicates the end of a/d conversion. bit 7 adf description 0 [clearing conditions] (initial value) when 0 is written in the adf flag after reading adf = 1 when the dtc is activated by an adi interrupt and addr is read 1 [setting conditions] single mode: when a/d conversion ends scan mode: when a/d conversion ends on all specified channels bit 6a/d interrupt enable (adie): selects enabling or disabling of interrupt (adi) requests at the end of a/d conversion. bit 6 adie description 0 a/d conversion end interrupt (adi) request is disabled (initial value) 1 a/d conversion end interrupt (adi) request is enabled
597 bit 5a/d start (adst): selects starting or stopping of a/d conversion. holds a value of 1 during a/d conversion. the adst bit can be set to 1 by software, a timer conversion start trigger, or the a/d external trigger input pin ( $'75* ). bit 5 adst description 0 a/d conversion stopped (initial value) 1 single mode: a/d conversion is started. cleared to 0 automatically when conversion on the specified channel ends scan mode: a/d conversion is started. conversion continues sequentially on the selected channels until adst is cleared to 0 by software, a reset, or a transition to standby mode or module stop mode bit 4scan mode (scan): selects single mode or scan mode as the a/d conversion operating mode. see section 20.4, operation, for single mode and scan mode operation. only set the scan bit while conversion is stopped. bit 4 scan description 0 single mode (initial value) 1 scan mode bit 3clock select (cks): sets the a/d conversion time. only change the conversion time while adst = 0. bit 3 cks description 0 conversion time = 266 states (max.) (initial value) 1 conversion time = 134 states (max.)
598 bits 2 to 0channel select 2 to 0 (ch2 to ch0): together with the scan bit, these bits select the analog input channel(s). one analog input channel can be switched to digital input. only set the input channel while conversion is stopped. group selection channel selection description ch2 ch1 ch0 single mode scan mode 0 0 0 an0 (initial value) an0 1 an1 an0, an1 1 0 an2 an0 to an2 1 an3 an0 to an3 1 0 0 an4 an4 1 an5 an4, an5 1 0 an6 or cin0 to cin7 an4, an5, an6 or cin0 to cin7 1 an7 or cin8 to cin15 an4, an5, an6 or cin0 to cin7 an7 or cin8 to cin15
599 20.2.3 a/d control register (adcr) 7 trgs1 0 r/w 6 trgs0 0 r/w 5 ? 1 4 ? 1 3 ? 1 0 ? 1 2 ? 1 1 ? 1 bit initial value read/write adcr is an 8-bit readable/writable register that enables or disables external triggering of a/d conversion operations. adcr is initialized to h'3f by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bits 7 and 6timer trigger select 1 and 0 (trgs1, trgs0): these bits select enabling or disabling of the start of a/d conversion by a trigger signal. only set bits trgs1 and trgs0 while conversion is stopped. bit 7 bit 6 trgs1 trgs0 description 0 0 start of a/d conversion by external trigger is disabled (initial value) 1 start of a/d conversion by external trigger is disabled 1 0 start of a/d conversion by external trigger (8-bit timer) is enabled 1 start of a/d conversion by external trigger pin is enabled bits 5 to 0reserved: these bits cannot be modified and are always read as 1.
600 20.2.4 keyboard comparator control register (kbcomp) bit 76543210 ire ircks2 ircks1 ircks0 kbade kbch2 kbch1 kbch0 initial value 00000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w kbcomp is an 8-bit readable/writable register that controls the sci2 irda function and selects the cin input channels for a/d conversion. kbcomp is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 4irda control: see the description in section 15.2.11, keyboard comparator control register (kbcomp). bit 3keyboard a/d enable (kbade): selects either analog input pins (an6, an7) or digital input pins (cin0 to cin7, cin8 to cin15) for a/d converter channel 6 and channel 7 input. bits 2 to 0keyboard a/d channel select 2 to 0 (kbch2 to kbch0): these bits select the channels for a/d conversion from among the digital input pins. only set the input channel while a/d conversion is stopped. bit 3 bit 2 bit 1 bit 0 kbade kbch2 kbch1 kbch0 a/d converter channel 6 input a/d converter channel 7 input 0 an6 an7 1 0 0 0 cin0 cin8 1 cin1 cin9 1 0 cin2 cin10 1 cin3 cin11 1 0 0 cin4 cin12 1 cin5 cin13 1 0 cin6 cin14 1 cin7 cin15
601 20.2.5 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp9 bit in mstpcr is set to 1, a/d converter operation stops at the end of the bus cycle and a transition is made to module stop mode. registers cannot be read or written to in module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 1module stop (mstp9): specifies the a/d converter module stop mode. mstpcrh bit 1 mstp9 description 0 a/d converter module stop mode is cleared 1 a/d converter module stop mode is set (initial value)
602 20.3 interface to bus master addra to addrd are 16-bit registers, but the data bus to the bus master is only 8 bits wide. therefore, in accesses by the bus master, the upper byte is accessed directly, but the lower byte is accessed via a temporary register (temp). a data read from addr is performed as follows. when the upper byte is read, the upper byte value is transferred to the cpu and the lower byte value is transferred to temp. next, when the lower byte is read, the temp contents are transferred to the cpu. when reading addr, always read the upper byte before the lower byte. it is possible to read only the upper byte, but if only the lower byte is read, incorrect data may be obtained. figure 20.2 shows the data flow for addr access. bus master (h'aa) addrnh (h'aa) addrnl (h'40) lower byte read addrnh (h'aa) addrnl (h'40) temp (h'40) temp (h'40) (n = a to d) (n = a to d) module data bus module data bus bus interface upper byte read bus master (h'40) bus interface figure 20.2 addr access operation (reading h'aa40)
603 20.4 operation the a/d converter operates by successive approximations with 10-bit resolution. it has two operating modes: single mode and scan mode. 20.4.1 single mode (scan = 0) single mode is selected when a/d conversion is to be performed on a single channel only. a/d conversion is started when the adst bit is set to 1 by software, or by external trigger input. the adst bit remains set to 1 during a/d conversion, and is automatically cleared to 0 when conversion ends. on completion of conversion, the adf flag is set to 1. if the adie bit is set to 1 at this time, an adi interrupt request is generated. the adf flag is cleared by writing 0 after reading adcsr. when the operating mode or analog input channel must be changed during analog conversion, to prevent incorrect operation, first clear the adst bit to 0 in adcsr to halt a/d conversion. after making the necessary changes, set the adst bit to 1 to start a/d conversion again. the adst bit can be set at the same time as the operating mode or input channel is changed. typical operations when channel 1 (an1) is selected in single mode are described next. figure 20.3 shows a timing diagram for this example. 1. single mode is selected (scan = 0), input channel an1 is selected (ch1 = 0, ch0 = 1), the a/d interrupt is enabled (adie = 1), and a/d conversion is started (adst = 1). 2. when a/d conversion is completed, the result is transferred to addrb. at the same time the adf flag is set to 1, the adst bit is cleared to 0, and the a/d converter becomes idle. 3. since adf = 1 and adie = 1, an adi interrupt is requested. 4. the a/d interrupt handling routine starts. 5. the routine reads adcsr, then writes 0 to the adf flag. 6. the routine reads and processes the conversion result (addrb). 7. execution of the a/d interrupt handling routine ends. after that, if the adst bit is set to 1, a/d conversion starts again and steps 2 to 7 are repeated.
604 adie adst adf state of channel 0 (an0) a/d conversion starts 2 1 addra addrb addrc addrd state of channel 1 (an1) state of channel 2 (an2) state of channel 3 (an3) note: * vertical arrows ( ) indicate instructions executed by software. set * set * clear * clear * a/d conversion result 1 a/d conversion a/d conversion result 2 read conversion result read conversion result idle idle idle idle idle idle a/d conversion set * figure 20.3 example of a/d converter operation (single mode, channel 1 selected)
605 20.4.2 scan mode (scan = 1) scan mode is useful for monitoring analog inputs in a group of one or more channels. when the adst bit is set to 1 by software, or by timer or external trigger input, a/d conversion starts on the first channel in the group (an0 when ch2 = 0; an4 when ch2 = 1). when two or more channels are selected, after conversion of the first channel ends, conversion of the second channel (an1 or an5) starts immediately. a/d conversion continues cyclically on the selected channels until the adst bit is cleared to 0. the conversion results are transferred for storage into the addr registers corresponding to the channels. when the operating mode or analog input channel must be changed during analog conversion, to prevent incorrect operation, first clear the adst bit to 0 in adcsr to halt a/d conversion. after making the necessary changes, set the adst bit to 1 to start a/d conversion again. the adst bit can be set at the same time as the operating mode or input channel is changed. typical operations when three channels (an0 to an2) are selected in scan mode are described next. figure 20.4 shows a timing diagram for this example. 1. scan mode is selected (scan = 1), scan group 0 is selected (ch2 = 0), analog input channels an0 to an2 are selected (ch1 = 1, ch0 = 0), and a/d conversion is started (adst = 1) 2. when a/d conversion of the first channel (an0) is completed, the result is transferred to addra. next, conversion of the second channel (an1) starts automatically. 3. conversion proceeds in the same way through the third channel (an2). 4. when conversion of all the selected channels (an0 to an2) is completed, the adf flag is set to 1 and conversion of the first channel (an0) starts again. if the adie bit is set to 1 at this time, an adi interrupt is requested after a/d conversion ends. 5. steps 2 to 4 are repeated as long as the adst bit remains set to 1. when the adst bit is cleared to 0, a/d conversion stops. after that, if the adst bit is set to 1, a/d conversion starts again from the first channel (an0).
606 adst adf addra addrb addrc addrd state of channel 0 (an0) state of channel 1 (an1) state of channel 2 (an2) state of channel 3 (an3) set * 1 clear * 1 idle notes: 1. vertical arrows ( ) indicate instructions executed by software. 2. data currently being converted is ignored. clear * 1 idle idle a/d conversion time idle continuous a/d conversion execution a/d conversion 1 idle idle idle idle idle transfer * 2 a/d conversion 3 a/d conversion 2 a/d conversion 5 a/d conversion 4 a/d conversion result 1 a/d conversion result 2 a/d conversion result 3 a/d conversion result 4 figure 20.4 example of a/d converter operation (scan mode, channels an0 to an2 selected)
607 20.4.3 input sampling and a/d conversion time the a/d converter has a built-in sample-and-hold circuit. the a/d converter samples the analog input at a time t d after the adst bit is set to 1, then starts conversion. figure 20.5 shows the a/d conversion timing. table 20.4 indicates the a/d conversion time. as indicated in figure 20.5, the a/d conversion time includes t d and the input sampling time. the length of t d varies depending on the timing of the write access to adcsr. the total conversion time therefore varies within the ranges indicated in table 20.4. in scan mode, the values given in table 20.4 apply to the first conversion time. in the second and subsequent conversions the conversion time is fixed at 256 states when cks = 0 or 128 states when cks = 1. (1) (2) t d t spl t conv input sampling timing adf address write signal legend: (1): adcsr write cycle (2): adcsr address t d : a/d conversion start delay t spl : input sampling time t conv : a/d conversion time figure 20.5 a/d conversion timing
608 table 20.4 a/d conversion time (single mode) cks = 0 cks = 1 item symbol min typ max min typ max a/d conversion start delay t d 10176 9 input sampling time t spl 6331 a/d conversion time t conv 259 266 131 134 note: values in the table are the number of states. 20.4.4 external trigger input timing a/d conversion can be externally triggered. when the trgs1 and trgs0 bits are set to 11 in adcr, external trigger input is enabled at the $'75* pin. a falling edge at the $'75* pin sets the adst bit to 1 in adcsr, starting a/d conversion. other operations, in both single and scan modes, are the same as when the adst bit is set to 1 by software. figure 20.6 shows the timing. ? adtrg internal trigger signal adst a/d conversion figure 20.6 external trigger input timing 20.5 interrupts the a/d converter generates an interrupt (adi) at the end of a/d conversion. the adi interrupt request can be enabled or disabled by the adie bit in adcsr.
609 20.6 usage notes the following points should be noted when using the a/d converter. setting range of analog power supply and other pins: 1. analog input voltage range the voltage applied to the ann analog input pins during a/d conversion should be in the range av ss ann av ref (n = 0 to 7). 2. digital input voltage range the voltage applied to the cinn digital input pins should be in the range av ss cinn av ref and v ss cinn v cc (n = 0 to 15). 3. relation between av cc , av ss and v cc , v ss as the relationship between av cc , av ss and v cc , v ss , set av ss = v ss . if the a/d converter is not used, the avcc and avss pins must on no account be left open. 4. setting range of avref pin: the reference voltage supplied via the avref pin should be in the range av ref av cc . if conditions 1 to 4 above are not met, the reliability of the device may be adversely affected. notes on board design: in board design, digital circuitry and analog circuitry should be as mutually isolated as possible, and layout in which digital circuit signal lines and analog circuit signal lines cross or are in close proximity should be avoided as far as possible. failure to do so may result in incorrect operation of the analog circuitry due to inductance, adversely affecting a/d conversion values. also, digital circuitry must be isolated from the analog input signals (an0 to an7), analog reference power supply (avref), and analog power supply (avcc) by the analog ground (avss). also, the analog ground (avss) should be connected at one point to a stable digital ground (vss) on the board. notes on noise countermeasures: a protection circuit connected to prevent damage due to an abnormal voltage such as an excessive surge at the analog input pins (an0 to an7) or analog reference power supply pin (avref) should be connected between avcc and avss as shown in figure 20.7. also, the bypass capacitors connected to avcc, avref and the filter capacitor connected to an0 to an7 must be connected to avss. if a filter capacitor is connected as shown in figure 20.7, the input currents at the analog input pins (an0 to an7) are averaged, and so an error may arise. also, when a/d conversion is performed frequently, as in scan mode, if the current charged and discharged by the capacitance of the sample-and-hold circuit in the a/d converter exceeds the current input via the input
610 impedance (r in ), an error will arise in the analog input pin voltage. careful consideration is therefore required when deciding the circuit constants. avcc * 1 avref an0 to an7 avss notes: figures are reference values. 1. 2. r in : input impedance * 1 r in * 2 100 0.1 f 0.01 f 10 f figure 20.7 example of analog input protection circuit table 20.5 analog pin ratings item min max unit analog input capacitance 20 pf permissible signal source impedance 10 * k w note: * when v cc = 4.0 to 5.5 v and ? 12 mhz. an0 to an7 10 k w 20 pf to a/d converter note: numeric values are reference values. figure 20.8 analog input pin equivalent circuit
611 a/d conversion precision definitions: h8s/2148 series and h8s/2144 series a/d conversion precision definitions are given below. resolution the number of a/d converter digital output codes offset error the deviation of the analog input voltage value from the ideal a/d conversion characteristic when the digital output changes from the minimum voltage value b'0000000000 (h'000) to b'0000000001 (h'001) (see figure 20.10). full-scale error the deviation of the analog input voltage value from the ideal a/d conversion characteristic when the digital output changes from b'1111111110 (h'3fe) to b'111111111 (h'3ff) (see figure 20.11). quantization error the deviation inherent in the a/d converter, given by 1/2 lsb (see figure 20.9). nonlinearity error the error with respect to the ideal a/d conversion characteristic between the zero voltage and the full-scale voltage. does not include the offset error, full-scale error, or quantization error. absolute precision the deviation between the digital value and the analog input value. includes the offset error, full-scale error, quantization error, and nonlinearity error.
612 h'3ff h'3fe h'3fd h'004 h'003 h'002 h'001 h'000 1 1024 2 1024 1023 1024 1022 1024 fs quantization error digital output ideal a/d conversion characteristic analog input voltage figure 20.9 a/d conversion precision definitions (1) fs offset error nonlinearity error actual a/d conversion characteristic analog input voltage digital output ideal a/d conversion characteristic full-scale error figure 20.10 a/d conversion precision definitions (2)
613 permissible signal source impedance: h8s/2148 series and h8s/2144 series analog input is designed so that conversion precision is guaranteed for an input signal for which the signal source impedance is 10 k w (avcc = 4.0 to 5.5 v, when ? 12 mhz) or less. this specification is provided to enable the a/d converters sample-and-hold circuit input capacitance to be charged within the sampling time; if the sensor output impedance exceeds 10 k w (avcc = 4.0 to 5.5 v, when ? 12 mhz), charging may be insufficient and it may not be possible to guarantee the a/d conversion precision. however, if a large capacitance is provided externally, the input load will essentially comprise only the internal input resistance of 10 k w , and the signal source impedance is ignored. but since a low-pass filter effect is obtained in this case, it may not be possible to follow an analog signal with a large differential coefficient (e.g., 5 mv/sec or greater). when converting a high-speed analog signal, a low-impedance buffer should be inserted. influences on absolute precision: adding capacitance results in coupling with gnd, and therefore noise in gnd may adversely affect absolute precision. be sure to make the connection to an electrically stable gnd such as av ss . care is also required to insure that filter circuits do not communicate with digital signals on the mounting board, so acting as antennas. a/d converter equivalent circuit h8s/2148 series or h8s/2144 series chip 20 pf c in = 15 pf 10 k low-pass filter c to 0.1 f sensor output impedance, up to 10 k w sensor input figure 20.11 example of analog input circuit
614
615 section 21 ram 21.1 overview the h8s/2148, h8s/2144 and h8s/2143 have 4 kbytes of on-chip high-speed static ram, and the h8s/2147 and h8s/2142 have 2 kbytes. the on-chip ram is connected to the cpu by a 16- bit data bus, enabling both byte data and word data to be accessed in one state. this makes it possible to perform fast word data transfer. the on-chip ram can be enabled or disabled by means of the ram enable bit (rame) in the system control register (syscr). 21.1.1 block diagram figure 21.1 shows a block diagram of the on-chip ram. internal data bus (upper 8 bits) internal data bus (lower 8 bits) h'ffe080 h'ffe082 h'ffe084 h'ffeffe h'ffe081 h'ffe083 h'ffe085 h'ffefff h'ffff00 h'ffff7e h'ffff01 h'ffff7f figure 21.1 block diagram of ram (h8s/2148, h8s/2144, h8s/2143)
616 21.1.2 register configuration the on-chip ram is controlled by syscr. table 21.1 shows the register configuration. table 21.1 register configuration name abbreviation r/w initial value address * system control register syscr r/w h'09 h'ffc4 note: * lower 16 bits of the address. 21.2 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write the on-chip ram is enabled or disabled by the rame bit in syscr. for details of other bits in syscr, see section 3.2.2, system control register (syscr). bit 0ram enable (rame): enables or disables the on-chip ram. the rame bit is initialized when the reset state is released. it is not initialized in software standby mode. bit 0 rame description 0 on-chip ram is disabled 1 on-chip ram is enabled (initial value)
617 21.3 operation 21.3.1 expanded mode (modes 1, 2, and 3 (expe = 1)) when the rame bit is set to 1, accesses to h8s/2148, h8s/2144, and h8s/2143 addresses h'(ff)e080 to h'(ff)efff and h'(ff)ff00 to h'(ff)ff7f, and h8s/2147 and h8s/2142 addresses h'(ff)e880 to h'(ff)efff and h'(ff)ff00 to h'(ff)ff7f, are directed to the on-chip ram. when the rame bit is cleared to 0, accesses to addresses h'(ff)e080 to h'(ff)efff and h'(ff)ff00 to h'(ff)ff7f, are directed to the off-chip address space. since the on-chip ram is connected to the bus master by a 16-bit data bus, it can be written to and read in byte or word units. each type of access is performed in one state. even addresses use the upper 8 bits, and odd addresses use the lower 8 bits. word data must start at an even address. 21.3.2 single-chip mode (modes 2 and 3 (expe = 0)) when the rame bit is set to 1, accesses to h8s/2148, h8s/2144, and h8s/2143 addresses h'(ff)e080 to h'(ff)efff and h'(ff)ff00 to h'(ff)ff7f, and h8s/2147 and h8s/2142 addresses h'(ff)e880 to h'(ff)efff and h'(ff)ff00 to h'(ff)ff7f, are directed to the on-chip ram. when the rame bit is cleared to 0, the on-chip ram is not accessed. a read will always return h'ff, and writes are invalid. since the on-chip ram is connected to the bus master by a 16-bit data bus, it can be written to and read in byte or word units. each type of access is performed in one state. even addresses use the upper 8 bits, and odd addresses use the lower 8 bits. word data must start at an even address.
618
619 section 22 rom 22.1 overview the h8s/2148 and h8s/2144 have 128 kbytes of on-chip rom (flash memory or mask rom), the h8s/2143 has 96 kbytes, and the h8s/2147 and h8s/2142 have 64 kbytes. the rom is connected to the cpu by a 16-bit data bus. the cpu accesses both byte and word data in one state, enabling faster instruction fetches and higher processing speed. the mode pins (md1 and md0) and the expe bit in mdcr can be set to enable or disable the on-chip rom. the flash memory versions of the h8s/2148, h8s/2144, and h8s/2142 can be erased and programmed on-board as well as with a general-purpose prom programmer. 22.1.1 block diagram figure 22.1 shows a block diagram of the rom. h'000000 h'000002 h'01fffe h'000001 h'000003 h'01ffff internal data bus (upper 8 bits) internal data bus (lower 8 bits) figure 22.1 rom block diagram (h8s/2148, h8s/2144)
620 22.1.2 register configuration the h8s/2148 series and h8s/2144 series on-chip rom is controlled by the operating mode and register mdcr. the register configuration is shown in table 22.1. table 22.1 rom register register name abbreviation r/w initial value address * mode control register mdcr r/w undefined depends on the operating mode h'ffc5 note: * lower 16 bits of the address. 22.2 register descriptions 22.2.1 mode control register (mdcr) bit initial value read/write 7 expe * r/w * 6 ? 0 5 ? 0 4 ? 0 3 ? 0 0 mds0 * r 2 ? 0 1 mds1 * r note: * determined by the md1 and md0 pins. mdcr is an 8-bit register used to set the h8s/2148 series or h8s/2144 series operating mode and monitor the current operating mode. the expe bit is initialized in accordance with the mode pin states by a reset and in hardware standby mode. bit 7expanded mode enable (expe): sets expanded mode. in mode 1, expe is fixed at 1 and cannot be modified. in modes 2 and 3, expe has an initial value of 0 and can be read or written. bit 7 expe description 0 single-chip mode selected 1 expanded mode selected
621 bits 6 to 2reserved: these bits cannot be modified and are always read as 0. bits 1 and 0mode select 1 and 0 (mds1, mds0): these bits indicate values that reflects the input levels of mode pins md1 and md0 (the current operating mode). bits mds1 and mds0 correspond to pins md1 and md0, respectively. these are read-only bits, and cannot be modified. when mdcr is read, the input levels of mode pins md1 and md0 are latched in these bits. 22.3 operation the on-chip rom is connected to the cpu by a 16-bit data bus, and both byte and word data is accessed in one state. even addresses are connected to the upper 8 bits, and odd addresses to the lower 8 bits. word data must start at an even address. the mode pins (md1 and md0) and the expe bit in mdcr can be set to enable or disable the on-chip rom, as shown in table 22.2. in normal mode, the maximum amount of rom that can be used is 56 kbytes. table 22.2 operating modes and rom operating mode mcu operating cpu operating mode pins mdcr mode mode description md1 md0 expe on-chip rom mode 1 normal expanded mode with on-chip rom disabled 0 1 1 disabled mode 2 advanced single-chip mode 1 0 0 enabled * advanced expanded mode with on-chip rom enabled 1 mode 3 normal single-chip mode 1 0 enabled normal expanded mode with on-chip rom enabled 1 (max. 56 kbytes) note: * 128 kbytes in the h8s/2148 and h8s/2144, 96 kbytes in the h8s/2143, and 64 kbytes in the h8s/2147 and h8s/2142.
622 22.4 overview of flash memory 22.4.1 features the features of the flash memory are summarized below. four flash memory operating modes ? program mode ? erase mode ? program-verify mode ? erase-verify mode programming/erase methods the flash memory is programmed 32 bytes at a time. erasing is performed by block erase (in single-block units). when erasing multiple blocks, the individual blocks must be erased sequentially. block erasing can be performed as required on 1-kbyte, 8-kbyte, 16-kbyte, 28- kbyte, and 32-kbyte blocks. programming/erase times the flash memory programming time is 10 ms (typ.) for simultaneous 32-byte programming, equivalent to 300 s (typ.) per byte, and the erase time is 100 ms (typ.) per block. reprogramming capability the flash memory can be reprogrammed up to 100 times. on-board programming modes there are two modes in which flash memory can be programmed/erased/verified on-board: ? boot mode ? user program mode automatic bit rate adjustment with data transfer in boot mode, the bit rate of the h8s/2148 series or h8s/2144 series chip can be automatically adjusted to match the transfer bit rate of the host. protect modes there are three protect modes, hardware, software, and error protect, which allow protected status to be designated for flash memory program/erase/verify operations. writer mode flash memory can be programmed/erased in writer mode, using a prom programmer, as well as in on-board programming mode.
623 22.4.2 block diagram module bus bus interface/controller flash memory (128 kbytes/64 kbytes) operating mode flmcr2 internal address bus internal data bus (16 bits) mode pins ebr1 ebr2 flmcr1 * * * * legend: flmcr1: flash memory control register 1 flmcr2: flash memory control register 2 ebr1: erase block register 1 ebr2: erase block register 2 note: * these registers are used only in the flash memory version. in the mask rom version, a read at any of these addresses will return an undefined value, and writes are invalid. figure 22.2 block diagram of flash memory
624 22.4.3 flash memory operating modes mode transitions: when the mode pins are set in the reset state and a reset-start is executed, the mcu enters one of the operating modes shown in figure 22.3. in user mode, flash memory can be read but not programmed or erased. flash memory can be programmed and erased in boot mode, user program mode, and writer mode. boot mode on-board programming mode user program mode user mode with on-chip rom enabled reset state writer mode res = 0 swe = 1 swe = 0 * 1 * 2 notes: only make a transition between user mode and user program mode when the cpu is not accessing the flash memory. 1. md0 = md1 = 0, p92 = p91 = p90 = 1 2. md0 = md1 = 0, p92 = 0, p91 = p90 = 1 res = 0 res = 0 res = 0 md1 = 1 figure 22.3 flash memory mode transitions
625 on-board programming modes boot mode flash memory h8s/2148 or h8s/2144 series chip ram host programming control program sci application program (old version)   programming control program new application program programming control program new application program flash memory h8s/2148 or h8s/2144 series chip ram host sci application program (old version) boot program area new application program flash memory h8s/2148 or h8s/2144 series chip ram host sci flash memory erase boot program flash memory h8s/2148 or h8s/2144 series chip program execution state ram host sci new application program boot program         1. initial state the flash memory is in the erased state when the device is shipped. the description here applies to the case where the old program version or data is being rewritten. the user should prepare the programming control program and new application program beforehand in the host. 2. programming control program transfer when boot mode is entered, the boot program in the h8s/2148 or h8s/2144 series chip (originally incorporated in the chip) is started, an sci communication check is carried out, and the boot program required for flash memory erasing is automatically transferred to the ram boot program area. 3. flash memory initialization the erase program in the boot program area (in ram) is executed, and the flash memory is initialized (to h'ff). in boot mode, entire flash memory erasure is performed, without regard to blocks. 4. writing new application program the programming control program transferred from the host to ram by sci communication is executed, and the new application program in the host is written into the flash memory. boot program boot program boot program area programming control program figure 22.4 boot mode
626 user program mode flash memory h8s/2148 or h8s/2144 series chip ram host programming/ erase control program sci boot program new application program flash memory h8s/2148 or h8s/2144 series chip ram host sci new application program flash memory h8s/2148 or h8s/2144 series chip ram host sci flash memory erase boot program new application program flash memory h8s/2148 or h8s/2144 series chip program execution state ram host sci boot program     boot program application program (old version)  new application program   1. initial state (1) the program that will transfer the programming/ erase control program to on-chip ram should be written into the flash memory by the user beforehand. (2) the programming/erase control program should be prepared in the host or in the flash memory. 2. programming/erase control program transfer the transfer program in the flash memory is executed, and the programming/erase control program is transferred to ram. 3. flash memory initialization the programming/erase program in ram is executed, and the flash memory is initialized (to h'ff). erasing can be performed in block units, but not in byte units. 4. writing new application program next, the new application program in the host is written into the erased flash memory blocks. do not write to unerased blocks. programming/ erase control program programming/ erase control program programming/ erase control program transfer program application program (old version) transfer program transfer program transfer program figure 22.5 user program mode (example)
627 differences between boot mode and user program mode boot mode user program mode entire memory erase yes yes block erase no yes programming control program * 1 * 3 * 2, 3 notes: 1. to be provided by the user, in accordance with the recommended algorithm. 2. erase/erase-verify 3. program/program-verify block configuration: the flash memory is divided into two 32-kbyte blocks (128-kbyte version only), two 8-kbyte blocks, one 16-kbyte block, one 28-kbyte block, and four 1-kbyte blocks. address h'00000 address h'0ffff address h'00000 1 kbyte 1 kbyte 1 kbyte 1 kbyte address h'1ffff 128 kbytes 32 kbytes (b) 64-kbyte version (a) 128-kbyte version 32 kbytes 8 kbytes 8 kbytes 16 kbytes 28 kbytes 1 kbyte 1 kbyte 1 kbyte 1 kbyte 8 kbytes 8 kbytes 16 kbytes 28 kbytes 64 kbytes figure 22.6 flash memory block configuration
628 22.4.4 pin configuration the flash memory is controlled by means of the pins shown in table 22.3. table 22.3 flash memory pins pin name abbreviation i/o function reset 5(6 input reset mode 1 md1 input sets mcu operating mode mode 0 md0 input sets mcu operating mode port 92 p92 input sets mcu operating mode when md1 = md0 = 0 port 91 p91 input sets mcu operating mode when md1 = md0 = 0 port 90 p90 input sets mcu operating mode when md1 = md0 = 0 transmit data txd1 output serial transmit data output receive data rxd1 input serial receive data input
629 22.4.5 register configuration the registers used to control the on-chip flash memory when enabled are shown in table 22.4. in order for these registers to be accessed, the flshe bit must be set to 1 in stcr. table 22.4 flash memory registers register name abbreviation r/w initial value address * 1 flash memory control register 1 flmcr1 * 5 r/w * 3 h'80 h'ff80 * 2 flash memory control register 2 flmcr2 * 5 r/w * 3 h'00 * 4 h'ff81 * 2 erase block register 1 ebr1 * 5 r/w * 3 h'00 * 4 h'ff82 * 2 erase block register 2 ebr2 * 5 r/w * 3 h'00 * 4 h'ff83 * 2 serial/timer control register stcr r/w h'00 h'ffc3 notes: 1. lower 16 bits of the address. 2. flash memory registers share addresses with other registers. register selection is performed by the flshe bit in the serial/timer control register (stcr). 3. in modes in which the on-chip flash memory is disabled, a read will return h'00, and writes are invalid. 4. when the swe bit in flmcr1 is not set, these registers are initialized to h'00. 5. flmcr1, flmcr2, ebr1, and ebr2 are 8-bit registers. only byte accesses are valid for these registers, the access requiring 2 states. these registers are used only in the flash memory version. in the mask rom version, a read at any of these addresses will return an undefined value, and writes are invalid.
630 22.5 register descriptions 22.5.1 flash memory control register 1 (flmcr1) bit 76543210 fwe swe ev pv e p initial value 10000000 read/write r r/w r/w r/w r/w r/w flmcr1 is an 8-bit register used for flash memory operating mode control. program-verify mode or erase-verify mode is entered by setting swe to 1. program mode is entered by setting swe to 1, then setting the psu bit in flmcr2, and finally setting the p bit. erase mode is entered by setting swe to 1, then setting the esu bit in flmcr2, and finally setting the e bit. flmcr1 is initialized to h'80 by a reset, and in hardware standby mode, software standby mode, subactive mode, subsleep mode, and watch mode. when on-chip flash memory is disabled, a read will return h'00, and writes are invalid. writes to the ev and pv bits in flmcr1 are enabled only when swe=1; writes to the e bit only when swe = 1, and esu = 1; and writes to the p bit only when swe = 1, and psu = 1. bit 7flash write enable bit (fwe): sets hardware protection against flash memory programming/erasing. this bit cannot be modified and is always read as 1. bit 6software write enable bit (swe): enables or disables flash memory programming. swe should be set before setting bits esu, psu, ev, pv, e, p, and eb9 to eb0, and should not be cleared at the same time as these bits. bit 6 swe description 0 writes disabled (initial value) 1 writes enabled bit 5 and 4reserved: these bits cannot be modified and are always read as 0.
631 bit 3erase-verify (ev): selects erase-verify mode transition or clearing. do not set the swe, esu, psu, pv, e, or p bit at the same time. bit 3 ev description 0 erase-verify mode cleared (initial value) 1 transition to erase-verify mode [setting condition] when swe = 1 bit 2program-verify (pv): selects program-verify mode transition or clearing. do not set the swe, esu, psu, ev, e, or p bit at the same time. bit 2 pv description 0 program-verify mode cleared (initial value) 1 transition to program-verify mode [setting condition] when swe = 1 bit 1erase (e): selects erase mode transition or clearing. do not set the swe, esu, psu, ev, pv, or p bit at the same time. bit 1 e description 0 erase mode cleared (initial value) 1 transition to erase mode [setting condition] when swe = 1, and esu = 1 bit 0program (p): selects program mode transition or clearing. do not set the swe, psu, esu, ev, pv, or e bit at the same time. bit 0 p description 0 program mode cleared (initial value) 1 transition to program mode [setting condition] when swe = 1, and psu = 1
632 22.5.2 flash memory control register 2 (flmcr2) bit 76543210 fler esupsu initial value 00000000 read/write r r/wr/w flmcr2 is an 8-bit register that monitors the presence or absence of flash memory program/erase protection (error protection) and performs setup for flash memory program/erase mode. flmcr2 is initialized to h'00 by a reset, and in hardware standby mode. the esu and psu bits are cleared to 0 in software standby mode, subactive mode, subsleep mode, and watch mode. when on-chip flash memory is disabled, a read will return h'00 and writes are invalid. bit 7flash memory error (fler): indicates that an error has occurred during an operation on flash memory (programming or erasing). when fler is set to 1, flash memory goes to the error-protection state. bit 7 fler description 0 flash memory is operating normally flash memory program/erase protection (error protection) is disabled [clearing condition] reset or hardware standby mode (initial value) 1 an error has occurred during flash memory programming/erasing flash memory program/erase protection (error protection) is enabled [setting condition] see section 22.8.3, error protection bits 6 to 2reserved: these bits cannot be modified and are always read as 0.
633 bit 1erase setup (esu): prepares for a transition to erase mode. set this bit to 1 before setting the e bit to 1 in flmcr1. do not set the swe, psu, ev, pv, e, or p bit at the same time. bit 1 esu description 0 erase setup cleared (initial value) 1 erase setup [setting condition] when swe = 1 bit 0program setup (psu): prepares for a transition to program mode. set this bit to 1 before setting the p bit to 1 in flmcr1. do not set the swe, esu, ev, pv, e, or p bit at the same time. bit 0 psu description 0 program setup cleared (initial value) 1 program setup [setting condition] when swe = 1
634 22.5.3 erase block registers 1 and 2 (ebr1, ebr2) bit 76543210 ebr1 eb9/ * 2 eb8/ * 2 initial value 00000000 read/write r/w * 1, * 2 r/w * 1, * 2 bit 76543210 ebr2 eb7 eb6 eb5 eb4 eb3 eb2 eb1 eb0 initial value 00000000 read/write r/w * 1 r/w r/w r/w r/w r/w r/w r/w notes: 1. in normal mode, these bits cannot be modified and are always read as 0. 2. bits eb8 and eb9 are not present in the 64-kbyte versions; they must not be set to 1. ebr1 and ebr2 are registers that specify the flash memory erase area block by block; bits 1 and 2 in ebr1 (128-kbyte versions only) and bits 7 to 0 in ebr2 are readable/writable bits. ebr1 and ebr2 are each initialized to h'00 by a reset, in hardware standby mode, software standby mode, subactive mode, subsleep mode, and watch mode, and when the swe bit in flmcr1 is not set. when a bit in ebr1 or ebr2 is set, the corresponding block can be erased. other blocks are erase-protected. set only one bit in ebr1 or ebr2 (more than one bit cannot be set). when on-chip flash memory is disabled, a read will return h'00, and writes are invalid. the flash memory block configuration is shown in table 22.5. table 22.5 flash memory erase blocks block (size) 128-kbyte versions 64-kbyte versions address eb0 (1 kbyte) eb0 (1 kbyte) h'(00)0000 to h'(00)03ff eb1 (1 kbyte) eb1 (1 kbyte) h'(00)0400 to h'(00)07ff eb2 (1 kbyte) eb2 (1 kbyte) h'(00)0800 to h'(00)0bff eb3 (1 kbyte) eb3 (1 kbytes) h'(00)0c00 to h'(00)0fff eb4 (28 kbytes) eb4 (28 kbytes) h'(00)1000 to h'(00)7fff eb5 (16 kbytes) eb5 (16 kbytes) h'(00)8000 to h'(00)bfff eb6 (8 kbytes) eb6 (8 kbytes) h'(00)c000 to h'(00)dfff eb7 (8 kbytes) eb7 (8 kbytes) h'00e000 to h'00ffff eb8 (32 kbytes) h'010000 to h'017fff eb9 (32 kbytes) h'018000 to h'01ffff
635 22.5.4 serial/timer control register (stcr) bit 76543210 iics iicx1 iicx0 iice flshe icks1 icks0 initial value 00000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w stcr is an 8-bit readable/writable register that controls register access, the iic operating mode (when the on-chip iic option is included), and on-chip flash memory (in f-ztat versions), and also selects the tcnt input clock. for details on functions not related to on-chip flash memory, see section 3.2.4, serial/timer control register (stcr), and descriptions of individual modules. if a module controlled by stcr is not used, do not write 1 to the corresponding bit. stcr is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 4i 2 c control (iics, iicx1, iicx0, iice): these bits control the operation of the i 2 c bus interface. for details, see section 16, i 2 c bus interface. bit 3flash memory control register enable (flshe): setting the flshe bit to 1 enables read/write access to the flash memory control registers. if flshe is cleared to 0, the flash memory control registers are deselected. in this case, the flash memory control register contents are retained. bit 3 flshe description 0 flash memory control registers deselected (initial value) 1 flash memory control registers selected bit 2reserved: do not write 1 to this bit. bits 1 and 0internal clock select 1 and 0 (icks1, icks0): these bits control 8-bit timer operation. see section 12, 8-bit timers, for details.
636 22.6 on-board programming modes when pins are set to on-board programming mode, program/erase/verify operations can be performed on the on-chip flash memory. there are two on-board programming modes: boot mode and user program mode. the pin settings for transition to each of these modes are shown in table 22.6. for a diagram of the transitions to the various flash memory modes, see figure 22.3. only advanced mode setting is possible for boot mode. in the case of user program mode, established in advanced mode or normal mode, depending on the setting of the md0 pin. in normal mode, only programming of a 56-kbyte area of flash memory is possible. table 22.6 setting on-board programming modes mode mode name cpu operating mode md1 md0 p92 p91 p90 boot mode advanced mode 0 0 1 * 1 * 1 * user program mode advanced mode 1 0 normal mode 1 note: * can be used as i/o ports after boot mode is initiated.
637 22.6.1 boot mode when boot mode is used, the flash memory programming control program must be prepared in the host beforehand. the channel 1 sci to be used is set to asynchronous mode. when a reset-start is executed after the h8s/2148 or h8s/2144 series mcus pins have been set to boot mode, the boot program built into the mcu is started and the programming control program prepared in the host is serially transmitted to the mcu via the sci. in the mcu, the programming control program received via the sci is written into the programming control program area in on-chip ram. after the transfer is completed, control branches to the start address of the programming control program area and the programming control program execution state is entered (flash memory programming is performed). the transferred programming control program must therefore include coding that follows the programming algorithm given later. the system configuration in boot mode is shown in figure 22.7, and the boot program mode execution procedure in figure 22.8. rxd1 txd1 sci1 h8s/2148 or h8s/2144 series chip flash memory write data reception verify data transmission host on-chip ram figure 22.7 system configuration in boot mode
638 note: if a memory cell does not operate normally and cannot be erased, one h'ff byte is transmitted as an erase error, and the erase operation and subsequent operations are halted. start set pins to boot mode and execute reset-start host transfers data (h'00) continuously at prescribed bit rate mcu measures low period of h'00 data transmitted by host mcu calculates bit rate and sets value in bit rate register after bit rate adjustment, transmits one h'00 data byte to host to indicate end of adjustment host confirms normal reception of bit rate adjustment end indication (h'00), and transmits one h'55 data byte after receiving h'55, mcu transfers part of boot program to ram host transmits number of user program bytes (n), upper byte followed by lower byte mcu transmits received number of bytes to host as verify data (echo-back) n = 1 host transmits user program sequentially in byte units mcu transmits received user program to host as verify data (echo-back) transfer received programming control program to on-chip ram n = n? no yes end of transmission check flash memory data, and if data has already been written, erase all blocks after confirming that all flash memory data has been erased, mcu transmits one h'aa data byte to host transmit one h'aa data byte to host, and execute programming control program transferred to on-chip ram n + 1 ? n figure 22.8 boot mode execution procedure
639 automatic sci bit rate adjustment start bit stop bit d0 d1 d2 d3 d4 d5 d6 d7 low period (9 bits) measured (h'00 data) high period (1 or more bits) figure 22.9 automatic sci bit rate adjustment when boot mode is initiated, the h8s/2148 or h8s/2144 series mcu measures the low period of the asynchronous sci communication data (h'00) transmitted continuously from the host. the sci transmit/receive format should be set as follows: 8-bit data, 1 stop bit, no parity. the mcu calculates the bit rate of the transmission from the host from the measured low period, and transmits one h'00 byte to the host to indicate the end of bit rate adjustment. the host should confirm that this adjustment end indication (h'00) has been received normally, and transmit one h'55 byte to the mcu. if reception cannot be performed normally, initiate boot mode again (reset), and repeat the above operations. depending on the hosts transmission bit rate and the mcus system clock frequency, there will be a discrepancy between the bit rates of the host and the mcu. to ensure correct sci operation, the hosts transfer bit rate should be set to (2400, 4800, or 9600) bps. table 22.7 shows typical host transfer bit rates and system clock frequencies for which automatic adjustment of the mcus bit rate is possible. the boot program should be executed within this system clock range. table 22.7 system clock frequencies for which automatic adjustment of h8s/2148 or h8s/2144 series bit rate is possible host bit rate system clock frequency for which automatic adjustment of h8s/2148 or h8s/2144 series bit rate is possible 9600 bps 8 mhz to 20 mhz 4800 bps 4 mhz to 20 mhz 2400 bps 2 mhz to 18 mhz
640 on-chip ram area divisions in boot mode: in boot mode, the 128-byte area from h'(ff)ff00 to h'(ff)ff7f is reserved for use by the boot program, as shown in figure 22.10. the area to which the programming control program is transferred is h'(ff)e080 to h'(ff)efff (3968 bytes) in the 128-kbyte versions, or h'(ff)e880 to h'(ff)efff (1920 bytes) in the 64- kbyte versions. the boot program area can be used when the programming control program transferred into ram enters the execution state. a stack area should be set up as required. h'(ff)e080 h'(ff)efff programming control program area (3,968 bytes) h'(ff)ff00 h'(ff)ff7f boot program area * (128 bytes) (a) 128-kbyte versions h'(ff)e880 h'(ff)efff programming control program area (1,920 bytes) h'(ff)ff00 h'(ff)ff7f boot program area * (128 bytes) (b) 64-kbyte versions note: * the boot program area cannot be used until a transition is made to the execution state for the programming control program transferred to ram. note that the boot program remains stored in this area after a branch is made to the programming control program. figure 22.10 ram areas in boot mode
641 notes on use of boot mode: when the chip comes out of reset in boot mode, it measures the low period of the input at the scis rxd1 pin. the reset should end with rxd1 high. after the reset ends, it takes about 100 states for the chip to get ready to measure the low period of the rxd1 input. in boot mode, if any data has been programmed into the flash memory (if all data is not 1), all flash memory blocks are erased. boot mode is for use when user program mode is unavailable, such as the first time on-board programming is performed, or if the program activated in user program mode is accidentally erased. interrupts cannot be used while the flash memory is being programmed or erased. the rxd1 and txd1 pins should be pulled up on the board. before branching to the programming control program (ram area h'(ff)e080 (128-kbyte versions) or h'(ff)e880 (64-kbyte versions)), the chip terminates transmit and receive operations by the on-chip sci (channel 1) (by clearing the re and te bits in scr to 0), but the adjusted bit rate value remains set in brr. the transmit data output pin, txd1, goes to the high-level output state (p84ddr = 1, p84dr = 1). the contents of the cpus internal general registers are undefined at this time, so these registers must be initialized immediately after branching to the programming control program. in particular, since the stack pointer (sp) is used implicitly in subroutine calls, etc., a stack area must be specified for use by the programming control program. the initial values of other on-chip registers are not changed. boot mode can be entered by making the pin settings shown in table 22.6 and executing a reset-start. when the chip detects the boot mode setting at reset release* 1 , p92, p91, and p90 can be used as i/o ports. boot mode can be cleared by driving the reset pin low, waiting at least 20 states, then setting the mode pins, and executing reset release* 1 . boot mode can also be cleared by a wdt overflow reset. the mode pin input levels must not be changed in boot mode. if the mode pin input levels are changed (for example, from low to high) during a reset, the state of ports with multiplexed address functions and bus control output pins ( $6 , 5' , +:5 ) will change according to the change in the microcomputers operating mode* 2 . therefore, care must be taken to make pin settings to prevent these pins from becoming output signal pins during a reset, or to prevent collision with signals outside the microcomputer. notes: 1. mode pins input must satisfy the mode programming setup time (t mds = 4 states) with respect to the reset release timing. 2. ports with multiplexed address functions will output a low level as the address signal if mode pin setting is for mode 1 is entered during a reset. in other modes, the port pins go to the high-impedance state. the bus control output signals will output a high level if mode pin setting is for mode 1 is entered during a reset. in other modes, the port pins go to the high-impedance state.
642 22.6.2 user program mode when set to user program mode, the chip can program and erase its flash memory by executing a user program/erase control program. therefore, on-board reprogramming of the on-chip flash memory can be carried out by providing an on-board means of supplying programming data, and storing a program/erase control program in part of the program area as necessary. to select user program mode, select a mode that enables the on-chip flash memory (mode 2 or 3). in this mode, on-chip supporting modules other than flash memory operate as they normally would in mode 2 and 3. the flash memory itself cannot be read while the swe bit is set to 1 to perform programming or erasing, so the control program that performs programming and erasing should be run in on-chip ram or external memory. figure 22.11 shows the procedure for executing the program/erase control program when transferred to on-chip ram. branch to flash memory application program branch to program/erase control program in ram area execute program/erase control program (flash memory rewriting) transfer program/erase control program to ram md1, md0 = 10, 11 reset-start write the transfer program (and the program/erase control program if necessary) beforehand note: the watchdog timer should be activated to prevent overprogramming or overerasing due to program runaway, etc. figure 22.11 user program mode execution procedure
643 22.7 programming/erasing flash memory in the on-board programming modes, flash memory programming and erasing is performed by software, using the cpu. there are four flash memory operating modes: program mode, erase mode, program-verify mode, and erase-verify mode. transitions to these modes can be made by setting the psu and esu bits in flmcr2, and the p, e, pv, and ev bits in flmcr1. the flash memory cannot be read while being programmed or erased. therefore, the program that controls flash memory programming/erasing (the programming control program) should be located and executed in on-chip ram or external memory. notes: 1. operation is not guaranteed if setting/resetting of the swe, ev, pv, e, and p bits in flmcr1, and the esu and psu bits in flmcr2, is executed by a program in flash memory. 2. perform programming in the erased state. do not perform additional programming on previously programmed addresses. 22.7.1 program mode follow the procedure shown in the program/program-verify flowchart in figure 22.12 to write data or programs to flash memory. performing program operations according to this flowchart will enable data or programs to be written to flash memory without subjecting the device to voltage stress or sacrificing program data reliability. programming should be carried out 32 bytes at a time. the wait times (x, y, z, a , ?, g, e, h) after setting/clearing individual bits in flash memory control registers 1 and 2 (flmcr1, flmcr2) and the maximum number of writes (n) are shown in table 25.14 in section 25.6, flash memory characteristics. following the elapse of (x) s or more after the swe bit is set to 1 in flash memory control register 1 (flmcr1), 32-byte program data is stored in the program data area and reprogram data area, and the 32-byte data in the reprogram data area written consecutively to the write addresses. the lower 8 bits of the first address written to must be h'00, h'20, h'40, h'60, h'80, h'a0, h'c0, or h'e0. thirty-two consecutive byte data transfers are performed. the program address and program data are latched in the flash memory. a 32-byte data transfer must be performed even if writing fewer than 32 bytes; in this case, h'ff data must be written to the extra addresses. next, the watchdog timer is set to prevent overprogramming in the event of program runaway, etc. set a value greater than (y + z + a + b ) m s as the wdt overflow period. after this, preparation for program mode (program setup) is carried out by setting the psu bit in flmcr2, and after the elapse of (y) s or more, the operating mode is switched to program mode by setting the p bit in flmcr1. the time during which the p bit is set is the flash memory
644 programming time. make a program setting so that the time for one programming operation is within the range of (z) s. 22.7.2 program-verify mode in program-verify mode, the data written in program mode is read to check whether it has been correctly written in the flash memory. after the elapse of a given programming time, the programming mode is exited (the p bit in flmcr1 is cleared, then the psu bit in flmcr2 is cleared at least ( a ) s later). the watchdog timer is cleared after the elapse of ( b ) s or more, and the operating mode is switched to program-verify mode by setting the pv bit in flmcr1. before reading in program-verify mode, a dummy write of h'ff data should be made to the addresses to be read. the dummy write should be executed after the elapse of ( g ) s or more. when the flash memory is read in this state (verify data is read in 16-bit units), the data at the latched address is read. wait at least ( e ) s after the dummy write before performing this read operation. next, the originally written data is compared with the verify data, and reprogram data is computed (see figure 22.12) and transferred to the reprogram data area. after 32 bytes of data have been verified, exit program- verify mode, wait for at least ( h ) s, then clear the swe bit in flmcr1. if reprogramming is necessary, set program mode again, and repeat the program/program-verify sequence as before. however, ensure that the program/program-verify sequence is not repeated more than (n) times on the same bits.
645 set swe bit in flmcr1 wait (x) m s n = 1 m = 0 write 32-byte data in ram reprogram data area consecutively to flash memory enable wdt set psu bit in flmcr2 wait (y) m s set p bit in flmcr1 wait (z) m s start of programming clear p bit in flmcr1 wait ( a ) m s wait ( b ) m s ng ng ng ng ok ok ok wait ( g ) m s wait ( e ) m s * 5 * 3 * 4 * 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 store 32-byte program data in program data area and reprogram data area * 4 * 1 * 3 * 5 wait ( h ) m s clear psu bit in flmcr2 disable wdt set pv bit in flmcr1 h'ff dummy write to verify address read verify data reprogram data computation clear pv bit in flmcr1 clear swe bit in flmcr1 m = 1 end of programming program data = verify data? end of 32-byte data verification? m = 0? increment address programming failure ok clear swe bit in flmcr1 n 3 n? n ? n + 1 notes: 1. data transfer is performed by byte transfer. the lower 8 bits of the first address written to must be h'00, h'20, h'40, h'60, h'80, h'a0, h'c0, or h'e0. a 32-byte data transfer must be performed even if writing fewer than 32 bytes; in this case, h'ff data must be written to the extra addresses. 2. verify data is read in 16-bit (word) units. 3. if a bit for which programming has been completed in the 32-byte programming loop fails the following verify phase, additional programming is performed for that bit. 4. an area for storing program data (32 bytes) and reprogram data (32 bytes) must be provided in ram. the contents of the latter are rewritten as programming progresses. 5. see section 25.6, flash memory characteristics, for the values of x, y, z, a , b , g , e , h , and n. start program data reprogram data comments reprogramming is not performed if program data and verify data match programming incomplete; reprogram ? still in erased state; no action ram program data storage area (32 bytes) reprogram data storage area (32 bytes) transfer reprogram data to reprogram data area verify data 1 0 1 1 0 1 0 1 0 0 1 1 end of programming perform programming in the erased state. do not perform additional programming on previously programmed addresses. figure 22.12 program/program-verify flowchart
646 22.7.3 erase mode flash memory erasing should be performed block by block following the procedure shown in the erase/erase-verify flowchart (single-block erase) shown in figure 22.13. to perform data or program erasure, make a 1 bit setting for the flash memory area to be erased in erase block register 1 or 2 (ebr1 or ebr2) at least (x) s after setting the swe bit to 1 in flash memory control register 1 (flmcr1). next, the watchdog timer is set to prevent overerasing in the event of program runaway, etc. set a value greater than (y + z + a + b ) ms as the wdt overflow period. after this, preparation for erase mode (erase setup) is carried out by setting the esu bit in flmcr2, and after the elapse of (y) s or more, the operating mode is switched to erase mode by setting the e bit in flmcr1. the time during which the e bit is set is the flash memory erase time. ensure that the erase time does not exceed (z) ms. note: with flash memory erasing, preprogramming (setting all data in the memory to be erased to 0) is not necessary before starting the erase procedure. 22.7.4 erase-verify mode in erase-verify mode, data is read after memory has been erased to check whether it has been correctly erased. after the elapse of the erase time, erase mode is exited (the e bit in flmcr1 is cleared, then the esu bit in flmcr2 is cleared at least ( a ) s later), the watchdog timer is cleared after the elapse of ( b ) s or more, and the operating mode is switched to erase-verify mode by setting the ev bit in flmcr1. before reading in erase-verify mode, a dummy write of h'ff data should be made to the addresses to be read. the dummy write should be executed after the elapse of ( g ) s or more. when the flash memory is read in this state (verify data is read in 16-bit units), the data at the latched address is read. wait at least ( e ) s after the dummy write before performing this read operation. if the read data has been erased (all 1), a dummy write is performed to the next address, and erase-verify is performed. if the read data has not been erased, set erase mode again, and repeat the erase/erase-verify sequence in the same way. however, ensure that the erase/erase-verify sequence is not repeated more than (n) times. when verification is completed, exit erase-verify mode, and wait for at least ( h ) s. if erasure has been completed on all the erase blocks, clear the swe bit in flmcr1. if there are any unerased blocks, make a 1 bit setting in ebr1 or ebr2 for the flash memory area to be erased, and repeat the erase/erase-verify sequence in the same way.
647 end of erasing start set swe bit in flmcr1 set esu bit in flmcr2 set e bit in flmcr1 wait (x) m s wait (y) m s n = 1 set ebr1, ebr2 enable wdt * 5 * 5 * 3 wait (z) ms * 5 wait ( a ) m s * 5 wait ( b ) m s * 5 wait ( g ) m s set block start address to verify address * 5 wait ( e ) m s * 5 * 2 * 5 wait ( h ) m s * 5 * 5 * 4 start of erase clear e bit in flmcr1 clear esu bit in flmcr2 set ev bit in flmcr1 h'ff dummy write to verify address read verify data clear ev bit in flmcr1 wait ( h ) m s clear ev bit in flmcr1 clear swe bit in flmcr1 disable wdt halt erase * 1 verify data = all 1? last address of block? end of erasing of all erase blocks? erase failure clear swe bit in flmcr1 n 3 n? ng ng ng ng ok ok ok ok n ? n + 1 increment address notes: 1. preprogramming (setting erase block data to all 0) is not necessary. 2. verify data is read in 16-bit (w) units. 3. set only one bit in ebr1or ebr2. more than one bit cannot be set. 4. erasing is performed in block units. to erase a number of blocks, the individual blocks must be erased sequentially. 5. see section 25.6, flash memory characteristics, for the values of x, y, z, a , b , g , e , h , and n. figure 22.13 erase/erase-verify flowchart (single-block erase)
648 22.8 flash memory protection there are three kinds of flash memory program/erase protection: hardware protection, software protection, and error protection. 22.8.1 hardware protection hardware protection refers to a state in which programming/erasing of flash memory is forcibly disabled or aborted. hardware protection is reset by settings in flash memory control registers 1 and 2 (flmcr1, flmcr2) and erase block registers 1 and 2 (ebr1, ebr2). (see table 22.8.) table 22.8 hardware protection functions item description program erase reset/standby protection in a reset (including a wdt overflow reset) and in hardware standby mode, software standby mode, subactive mode, subsleep mode, and watch mode, flmcr1, flmcr2, ebr1, and ebr2 are initialized, and the program/erase- protected state is entered. in a reset via the 5(6 pin, the reset state is not entered unless the 5(6 pin is held low until oscillation stabilizes after powering on. in the case of a reset during operation, hold the 5(6 pin low for the 5(6 pulse width specified in the ac characteristics section. yes yes
649 22.8.2 software protection software protection can be implemented by setting the swe bit in flmcr1 and erase block registers 1 and 2 (ebr1, ebr2). when software protection is in effect, setting the p or e bit in flash memory control register 1 (flmcr1) does not cause a transition to program mode or erase mode. (see table 22.9.) table 22.9 software protection functions item description program erase swe bit protection clearing the swe bit to 0 in flmcr1 sets the program/erase-protected state for all blocks. (execute in on-chip ram or external memory.) yes yes block specification protection erase protection can be set for individual blocks by settings in erase block registers 1 and 2 (ebr1, ebr2). setting ebr1 and ebr2 to h'00 places all blocks in the erase-protected state. yes
650 22.8.3 error protection in error protection, an error is detected when mcu runaway occurs during flash memory programming/erasing, or operation is not performed in accordance with the program/erase algorithm, and the program/erase operation is aborted. aborting the program/erase operation prevents damage to the flash memory due to overprogramming or overerasing. if the mcu malfunctions during flash memory programming/erasing, the fler bit is set to 1 in flmcr2 and the error protection state is entered. the flmcr1, flmcr2, ebr1, and ebr2 settings are retained, but program mode or erase mode is aborted at the point at which the error occurred. program mode or erase mode cannot be re-entered by re-setting the p or e bit. however, pv and ev bit setting is enabled, and a transition can be made to verify mode. fler bit setting conditions are as follows: when flash memory is read during programming/erasing (including a vector read or instruction fetch) immediately after exception handling (excluding a reset) during programming/erasing when a sleep instruction (including software standby, sleep, subactive, subsleep and watch mode) is executed during programming/erasing when the bus is released during programming/erasing error protection is released only by a reset and in hardware standby mode. figure 22.14 shows the flash memory state transition diagram.
651 rd vf pr er fler = 0 error occurrence * 1 res = 0 or stby = 0 res = 0 or stby = 0 rd vf pr er fler = 0 program mode erase mode reset or hardware standby (hardware protection) rd vf * 4 pr er fler = 1 rd vf pr er fler = 1 error protection mode error protection mode (software standby, sleep, subsleep, and watch ) software standby, sleep, subsleep, and watch mode flmcr1, flmcr2 (except fler bit), ebr1, ebr2 initialization state * 3 flmcr1, flmcr2, ebr1, ebr2 initialization state software standby, sleep, subsleep, and watch mode release rd: memory read possible vf: verify-read possible pr: programming possible er: erasing possible rd : memory read not possible vf : verify-read not possible pr : programming not possible er : erasing not possible legend: res = 0 or stby = 0 error occurrence * 2 notes: 1. when an error occurs other than due to a sleep instruction, or when a sleep instruction is executed for a transition to subactive mode 2. when an error occurs due to a sleep instruction (except subactive mode) 3. except sleep mode 4. vf in subactive mode figure 22.14 flash memory state transitions
652 22.9 interrupt handling when programming/erasing flash memory all interrupts, including nmi input is disabled when flash memory is being programmed or erased (when the p or e bit is set in flmcr1), and while the boot program is executing in boot mode* 1 , to give priority to the program or erase operation. there are three reasons for this: 1. interrupt during programming or erasing might cause a violation of the programming or erasing algorithm, with the result that normal operation could not be assured. 2. in the interrupt exception handling sequence during programming or erasing, the vector would not be read correctly* 2 , possibly resulting in mcu runaway. 3. if interrupt occurred during boot program execution, it would not be possible to execute the normal boot mode sequence. for these reasons, in on-board programming mode alone there are conditions for disabling interrupt, as an exception to the general rule. however, this provision does not guarantee normal erasing and programming or mcu operation. all interrupt requests, including nmi input, must therefore be disabled inside and outside the mcu when programming or erasing flash memory. interrupt is also disabled in the error-protection state while the p or e bit remains set in flmcr1. notes: 1. interrupt requests must be disabled inside and outside the mcu until the programming control program has completed programming. 2. the vector may not be read correctly in this case for the following two reasons: ? if flash memory is read while being programmed or erased (while the p or e bit is set in flmcr1), correct read data will not be obtained (undetermined values will be returned). ? if the interrupt entry in the vector table has not been programmed yet, interrupt exception handling will not be executed correctly.
653 22.10 flash memory writer mode 22.10.1 writer mode setting programs and data can be written and erased in writer mode as well as in the on-board programming modes. in writer mode, the on-chip rom can be freely programmed using a prom programmer that supports hitachi microcomputer device types with 128-kbyte or 64- kbyte on-chip flash memory. flash memory read mode, auto-program mode, auto-erase mode, and status read mode are supported with these device types. in auto-program mode, auto-erase mode, and status read mode, a status polling procedure is used, and in status read mode, detailed internal signals are output after execution of an auto-program or auto-erase operation. table 22.10 shows writer mode pin settings. table 22.10 writer mode pin settings pin names setting/external circuit connection mode pins: md1, md0 low-level input to md1, md0 67%< pin high-level input (hardware standby mode not set) 5(6 pin power-on reset circuit xtal and extal pins oscillation circuit other setting pins: p97, p92, p91, p90, p67 low-level input to p92, p67, high-level input to p97, p91, p90 22.10.2 socket adapters and memory map in writer mode, a socket adapter is mounted on the writer programmer to match the package concerned. socket adapters are available for each writer manufacturer supporting hitachi microcomputer device types with 128-kbyte or 64-kbyte on-chip flash memory. figure 22.15 shows the memory map in writer mode. for pin names in writer mode, see section 1.3.2, pin functions in each operating mode. h8s/2148 h8s/2144 h'000000 mcu mode writer mode h'01ffff h'00000 h'1ffff on-chip rom area h'000000 mcu mode writer mode h'00000 h'1ffff h'00ffff h'0ffff on-chip rom area undefined value output h8s/2142 figure 22.15 memory map in writer mode
654 22.10.3 writer mode operation table 22.11 shows how the different operating modes are set when using writer mode, and table 22.12 lists the commands used in writer mode. details of each mode are given below. memory read mode memory read mode supports byte reads. auto-program mode auto-program mode supports programming of 128 bytes at a time. status polling is used to confirm the end of auto-programming. auto-erase mode auto-erase mode supports automatic erasing of the entire flash memory. status polling is used to confirm the end of auto-erasing. status read mode status polling is used for auto-programming and auto-erasing, and normal termination can be confirmed by reading the fo6 signal. in status read mode, error information is output if an error occurs. table 22.11 settings for each operating mode in writer mode pin names mode &( &( 2( 2( :( :( fo0 to fo7 fa0 to fa17 read l l h data output ain output disable l h h hi-z x command write l h l data input ain * 2 chip disable * 1 h x x hi-z x notes: 1. chip disable is not a standby state; internally, it is an operation state. 2. ain indicates that there is also address input in auto-program mode. table 22.12 writer mode commands number 1st cycle 2nd cycle command name of cycles mode address data mode address data memory read mode 1 + n write x h'00 read ra dout auto-program mode 129 write x h'40 write wa din auto-erase mode 2 write x h'20 write x h'20 status read mode 2 write x h'71 write x h'71 notes: 1. in auto-program mode. 129 cycles are required for command writing by a simultaneous 128-byte write. 2. in memory read mode, the number of cycles depends on the number of address write cycles (n).
655 22.10.4 memory read mode after the end of an auto-program, auto-erase, or status read operation, the command wait state is entered. to read memory contents, a transition must be made to memory read mode by means of a command write before the read is executed. command writes can be performed in memory read mode, just as in the command wait state. once memory read mode has been entered, consecutive reads can be performed. after power-on, memory read mode is entered. table 22.13 ac characteristics in memory read mode (conditions: v cc = 5.0 v 10%, v ss = 0 v, t a = 25c 5c) item symbol min max unit notes command write cycle t nxtc 20 s &( hold time t ceh 0ns &( setup time t ces 0ns data hold time t dh 50 ns data setup time t ds 50 ns write pulse width t wep 70 ns :( rise time t r 30 ns :( fall time t f 30 ns ce fa17 to fa0 fo7 to fo0 data oe we command write t wep t ceh t dh t ds t f t r t nxtc note: data is latched on the rising edge of we . t ces memory read mode address stable data figure 22.16 memory read mode timing waveforms after command write
656 table 22.14 ac characteristics when entering another mode from memory read mode (conditions: v cc = 5.0 v 10%, v ss = 0 v, t a = 25c 5c) item symbol min max unit notes command write cycle t nxtc 20 s &( hold time t ceh 0ns &( setup time t ces 0ns data hold time t dh 50 ns data setup time t ds 50 ns write pulse width t wep 70 ns :( rise time t r 30 ns :( fall time t f 30 ns ce fa17 to fa0 fo7 to fo0 h'xx oe we other mode command write memory read mode t wep t ceh t dh t ds t nxtc t ces address stable data t f t r note: do not enable we and oe at the same time. figure 22.17 timing waveforms when entering another mode from memory read mode
657 table 22.15 ac characteristics in memory read mode (conditions: v cc = 5.0 v 10%, v ss = 0 v, t a = 25c 5c) item symbol min max unit notes access time t acc 20 s &( output delay time t ce 150 ns 2( output delay time t oe 150 ns output disable delay time t df 100 ns data output hold time t oh 5ns ce fa17 to fa0 fo7 to fo0 vil vil vih oe we t acc t acc address stable address stable data data t oh t oh figure 22.18 timing waveforms for &( &( / 2( 2( enable state read ce fa17 to fa0 fo7 to fo0 vih oe we t ce t acc t oe t oh t oh t df t ce t acc t oe address stable address stable data data t df figure 22.19 timing waveforms for &( &( / 2( 2( clocked read
658 22.10.5 auto-program mode ac characteristics table 22.16 ac characteristics in auto-program mode (conditions: v cc = 5.0 v 10%, v ss = 0 v, t a = 25c 5c) item symbol min max unit notes command write cycle t nxtc 20 s &( hold time t ceh 0ns &( setup time t ces 0ns data hold time t dh 50 ns data setup time t ds 50 ns write pulse width t wep 70 ns status polling start time t wsts 1ms status polling access time t spa 150 ns address setup time t as 0ns address hold time t ah 60 ns memory write time t write 1 3000 ms :( rise time t r 30 ns :( fall time t f 30 ns data ce fa17 to fa0 fo7 to fo0 fo6 fo7 oe we t nxtc t wsts t nxtc t ces t ds t dh t wep t as t ah t ceh address stable programming wait data transfer 1 byte to 128 bytes h'40 data fo0 to 5 = 0 t f t r t spa t write (1 to 3000 ms) programming normal end identification signal programming operation end identification signal figure 22.20 auto-program mode timing waveforms
659 notes on use of auto-program mode in auto-program mode, 128 bytes are programmed simultaneously. this should be carried out by executing 128 consecutive byte transfers. a 128-byte data transfer is necessary even when programming fewer than 128 bytes. in this case, h'ff data must be written to the extra addresses. the lower 8 bits of the transfer address must be h'00 or h'80. if a value other than an effective address is input, processing will switch to a memory write operation but a write error will be flagged. memory address transfer is performed in the second cycle (figure 22.20). do not perform transfer after the second cycle. do not perform a command write during a programming operation. perform one auto-programming operation for a 128-byte block for each address. characteristics are not guaranteed for two or more programming operations. confirm normal end of auto-programming by checking fo6. alternatively, status read mode can also be used for this purpose (fo7 status polling uses the auto-program operation end identification pin). the status polling fo6 and fo7 pin information is retained until the next command write. until the next command write is performed, reading is possible by enabling &( and 2( .
660 22.10.6 auto-erase mode ac characteristics table 22.17 ac characteristics in auto-erase mode (conditions: v cc = 5.0 v 10%, v ss = 0 v, t a = 25c 5c) item symbol min max unit notes command write cycle t nxtc 20 s &( hold time t ceh 0ns &( setup time t ces 0ns data hold time t dh 50 ns data setup time t ds 50 ns write pulse width t wep 70 ns status polling start time t ests 1ms status polling access time t spa 150 ns memory erase time t erase 100 40000 ms :( rise time t r 30 ns :( fall time t f 30 ns ce fa17 to fa0 fo7 to fo0 fo6 fo7 oe we t ests t nxtc t nxtc t ces t ceh t dh cl in dl in t wep fo0 to fo5 = 0 h'20 h'20 erase normal end confirmation signal t f t r t ds t spa t erase (100 to 40000 ms) erase end identification signal figure 22.21 auto-erase mode timing waveforms
661 notes on use of erase-program mode auto-erase mode supports only entire memory erasing. do not perform a command write during auto-erasing. confirm normal end of auto-erasing by checking fo6. alternatively, status read mode can also be used for this purpose (fo7 status polling uses the auto-erase operation end identification pin). the status polling fo6 and fo7 pin information is retained until the next command write. until the next command write is performed, reading is possible by enabling &( and 2( . 22.10.7 status read mode status read mode is used to identify what type of abnormal end has occurred. use this mode when an abnormal end occurs in auto-program mode or auto-erase mode. the return code is retained until a command write for other than status read mode is performed. table 22.18 ac characteristics in status read mode (conditions: v cc = 5.0 v 10%, v ss = 0 v, t a = 25c 5c) item symbol min max unit notes command write cycle t nxtc 20 s &( hold time t ceh 0ns &( setup time t ces 0ns data hold time t dh 50 ns data setup time t ds 50 ns write pulse width t wep 70 ns 2( output delay time t oe 150 ns disable delay time t df 100 ns &( output delay time t ce 150 ns :( rise time t r 30 ns :( fall time t f 30 ns
662 ce fa17 to fa0 fo7 to fo0 oe we t ces t nxtc t nxtc t df note: fo2 and fo3 are undefined. t ces t dh t wep t wep data t dh t oe t ce t nxtc h'71 t f t r t f t r t ceh t ds t ds h'71 t ceh figure 22.22 status read mode timing waveforms table 22.19 status read mode return commands pin name fo7 fo6 fo5 fo4 fo3 fo2 fo1 fo0 attribute normal end identification command error programming error erase error programming or erase count exceeded effective address error initial value 00000000 indications normal end: 0 abnormal end: 1 command error: 1 otherwise: 0 programming error: 1 otherwise: 0 erase error: 1 otherwise: 0 count exceeded: 1 otherwise: 0 effective address error: 1 otherwise: 0 note: fo2 and fo3 are undefined.
663 22.10.8 status polling the fo7 status polling flag indicates the operating status in auto-program or auto-erase mode. the fo6 status polling flag indicates a normal or abnormal end in auto-program or auto- erase mode. table 22.20 status polling output truth table pin names internal operation in progress abnormal end normal end fo7 0 1 0 1 fo6 0 0 1 1 fo0 to fo5 0 0 0 0 22.10.9 writer mode transition time commands cannot be accepted during the oscillation stabilization period or the writer mode setup period. after the writer mode setup time, a transition is made to memory read mode. table 22.21 command wait state transition time specifications item symbol min max unit notes standby release (oscillation stabilization time) t osc1 20 ms writer mode setup time t bmv 10 ms v cc hold time t dwn 0ms v cc res memory read mode command wait state command wait state normal/ abnormal end identification auto-program mode auto-erase mode t osc1 t bmv t dwn don't care command acceptance figure 22.23 oscillation stabilization time, writer mode setup time, and power supply fall sequence
664 22.10.10 notes on memory programming when programming addresses which have previously been programmed, carry out auto- erasing before auto-programming. when performing programming using writer mode on a chip that has been programmed/erased in an on-board programming mode, auto-erasing is recommended before carrying out auto-programming. notes: 1. the flash memory is initially in the erased state when the device is shipped by hitachi. for other chips for which the erasure history is unknown, it is recommended that auto-erasing be executed to check and supplement the initialization (erase) level. 2. auto-programming should be performed once only on the same address block. 22.11 flash memory programming and erasing precautions precautions concerning the use of on-board programming mode and writer mode are summarized below. use the specified voltages and timing for programming and erasing: applied voltages in excess of the rating can permanently damage the device. use a prom programmer that supports hitachi microcomputer device types with 128-kbyte or 64-kbyte on-chip flash memory. do not select the hn28f101 setting for the prom programmer, and only use the specified socket adapter. incorrect use will result in damaging the device. powering on and off: when applying or disconnecting v cc , fix the 5(6 pin low and place the flash memory in the hardware protection state. the power-on and power-off timing requirements should also be satisfied in the event of a power failure and subsequent recovery. use the recommended algorithm when programming and erasing flash memory: the recommended algorithm enables programming and erasing to be carried out without subjecting the device to voltage stress or sacrificing program data reliability. when setting the p or e bit in flmcr1, the watchdog timer should be set beforehand as a precaution against program runaway, etc. do not set or clear the swe bit during program execution in flash memory: clear the swe bit before executing a program or reading data in flash memory. when the swe bit is set, data in flash memory can be rewritten, but flash memory should only be accessed for verify operations (verification during programming/erasing).
665 do not use interrupts while flash memory is being programmed or erased: all interrupt requests, including nmi, should be disabled when programming and erasing flash memory to give priority to program/erase operations. do not perform additional programming. erase the memory before reprogramming. in on- board programming, perform only one programming operation on a 32-byte programming unit block. in writer mode, too, perform only one programming operation on a 128-byte programming unit block. programming should be carried out with the entire programming unit block erased. before programming, check that the chip is correctly mounted in the prom programmer. overcurrent damage to the device can result if the index marks on the prom programmer socket, socket adapter, and chip are not correctly aligned. do not touch the socket adapter or chip during programming. touching either of these can cause contact faults and write errors.
666
667 section 23 clock pulse generator 23.1 overview the h8s/2148 series and h8s/2144 series have a built-in clock pulse generator (cpg) that generates the system clock (?), the bus master clock, and internal clocks. the clock pulse generator consists of an oscillator circuit, a duty adjustment circuit, clock selection circuit, medium-speed clock divider, bus master clock selection circuit, subclock input circuit, and waveform shaping circuit. 23.1.1 block diagram figure 23.1 shows a block diagram of the clock pulse generator. extal xtal oscillator duty adjustment circuit excl subclock input circuit waveform shaping circuit medium-speed clock divider system clock to ?pin wdt1 count clock internal clock to supporting modules bus master clock to cpu, dtc ?2 to ?32 sub bus master clock selection circuit clock selection circuit figure 23.1 block diagram of clock pulse generator 23.1.2 register configuration the clock pulse generator is controlled by the standby control register (sbycr) and low-power control register (lpwrcr). table 23.1 shows the register configuration. table 23.1 cpg registers name abbreviation r/w initial value address * standby control register sbycr r/w h'00 h'ff84 low-power control register lpwrcr r/w h'00 h'ff85 note: * lower 16 bits of the address.
668 23.2 register descriptions 23.2.1 standby control register (sbycr) 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 ? 0 0 sck0 0 r/w 2 sck2 0 r/w 1 sck1 0 r/w bit initial value read/write sbycr is an 8-bit readable/writable register that performs power-down mode control. only bits 0 to 2 are described here. for a description of the other bits, see section 24.2.1, standby control register (sbycr). sbycr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 2 to 0system clock select 2 to 0 (sck2 to sck0): these bits select the bus master clock for high-speed mode and medium-speed mode. when operating the device after a transition to subactive mode or watch mode bits sck2 to sck0 should all be cleared to 0. bit 2 bit 1 bit 0 sck2 sck1 sck0 description 0 0 0 bus master is in high-speed mode (initial value) 1 medium-speed clock is ?/2 1 0 medium-speed clock is ?/4 1 medium-speed clock is ?/8 1 0 0 medium-speed clock is ?/16 1 medium-speed clock is ?/32 1
669 23.2.2 low-power control register (lpwrcr) 7 dton 0 r/w 6 lson 0 r/w 5 nesel 0 r/w 4 excle 0 r/w 3 ? 0 0 ? 0 2 ? 0 1 ? 0 bit initial value read/write lpwrcr is an 8-bit readable/writable register that performs power-down mode control. only bit 4 is described here. for a description of the other bits, see section 24.2.2, low-power control register (lpwrcr). lpwrcr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 4subclock input enable (excle): controls subclock input from the excl pin. bit 4 excle description 0 subclock input from excl pin is disabled (initial value) 1 subclock input from excl pin is enabled
670 23.3 oscillator clock pulses can be supplied by connecting a crystal resonator, or by input of an external clock. 23.3.1 connecting a crystal resonator circuit configuration: a crystal resonator can be connected as shown in the example in figure 23.2. select the damping resistance r d according to table 23.2. an at-cut parallel-resonance crystal should be used. extal xtal r d c l2 c l1 c l1 = c l2 = 10 to 22pf figure 23.2 connection of crystal resonator (example) table 23.2 damping resistance value frequency (mhz) 2 4 8 10 12 16 20 r d ( w ) 1k 500 200 0 0 0 0 crystal resonator: figure 23.3 shows the equivalent circuit of the crystal resonator. use a crystal resonator that has the characteristics shown in table 23.3 and the same frequency as the system clock (?). xtal c l at-cut parallel-resonance type extal c 0 lr s figure 23.3 crystal resonator equivalent circuit
671 table 23.3 crystal resonator parameters frequency (mhz) 24810121620 r s max ( w ) 500 120 80 70 60 50 40 c 0 max (pf) 7777777 note on board design: when a crystal resonator is connected, the following points should be noted. other signal lines should be routed away from the oscillator circuit to prevent induction from interfering with correct oscillation. see figure 23.4. when designing the board, place the crystal resonator and its load capacitors as close as possible to the xtal and extal pins. c l2 signal a signal b c l1 h8s/2148 series or h8s/2144 series chip xtal extal avoid figure 23.4 example of incorrect board design
672 23.3.2 external clock input circuit configuration: an external clock signal can be input as shown in the examples in figure 23.5. if the xtal pin is left open, make sure that stray capacitance is no more than 10 pf. in example (b), make sure that the external clock is held high in standby mode, subactive mode, subsleep mode, and watch mode. extal xtal external clock input open (a) xtal pin left open extal xtal external clock input (b) complementary clock input at xtal pin figure 23.5 external clock input (examples) external clock: the external clock signal should have the same frequency as the system clock (?). table 23.4 and figure 23.6 show the input conditions for the external clock.
673 table 23.4 external clock input conditions v cc = 2.7 to 5.5 v v cc = 5.0 v 10% item symbol min max min max unit test conditions external clock input low pulse width t exl 40 20 ns figure 23.6 external clock input high pulse width t exh 40 20 ns external clock rise time t exr 10 5 ns external clock fall time t exf 10 5 ns clock low pulse width t cl 0.4 0.6 0.4 0.6 t cyc ? 3 5 mhz figure 25.4 80 80 ns ? < 5 mhz clock high pulse width t ch 0.4 0.6 0.4 0.6 t cyc ? 3 5 mhz 80 80 ns ? < 5 mhz t exh t exl t exr t exf v cc 0.5 extal figure 23.6 external clock input timing table 23.5 shows the external clock output settling delay time, and figure 23.7 shows the external clock output settling delay timing. the oscillator and duty adjustment circuit have a function for adjusting the waveform of the external clock input at the extal pin. when the prescribed clock signal is input at the extal pin, internal clock signal output is fixed after the elapse of the external clock output settling delay time (t dext ). as the clock signal output is not fixed during the t dext period, the reset signal should be driven low to maintain the reset state.
674 table 23.5 external clock output settling delay time conditions: v cc = 2.7 v to 5.5 v, av cc = 2.7 v to 5.5 v, v ss = av ss = 0 v item symbol min max unit notes external clock output settling delay time t dext * 500 s figure 23.7 note: * t dext includes 5(6 pulse width (t resw ). t dext * res (internal or external) extal stby v cc 2.7v v ih ? note: * t dext includes res pulse width (t resw ). figure 23.7 external clock output settling delay timing
675 23.4 duty adjustment circuit when the oscillator frequency is 5 mhz or higher, the duty adjustment circuit adjusts the duty cycle of the clock signal from the oscillator to generate the system clock (?). 23.5 medium-speed clock divider the medium-speed clock divider divides the system clock to generate ?/2, ?/4, ?/8, ?/16, and ?/32 clocks. 23.6 bus master clock selection circuit the bus master clock selection circuit selects the system clock (?) or one of the medium-speed clocks (?/2, ?/4, ?/8, ?/16, or ?/32) to be supplied to the bus master, according to the settings of bits sck2 to sck0 in sbycr. 23.7 subclock input circuit the subclock input circuit controls the subclock input from the excl pin. inputting the subclock: when a subclock is used, a 32.768 khz external clock should be input from the excl pin. in this case, clear bit p96ddr to 0 in p9ddr and set bit excle to 1 in lpwrcr. the subclock input conditions are shown in table 23.6 and figure 23.8. table 23.6 subclock input conditions v cc = 2.7 to 5.5 v item symbol min typ max unit test conditions subclock input low pulse width t excll 15.26 s figure 23.8 subclock input high pulse width t exclh 15.26 s subclock input rise time t exclr 10ns subclock input fall time t exclf 10ns
676 t exclh t excll t exclr t exclf v cc 0.5 excl figure 23.8 subclock input timing when subclock is not needed: do not enable subclock input when the subclock is not needed 23.8 subclock waveform shaping circuit to eliminate noise in the subclock input from the excl pin, this circuit samples the clock using a clock obtained by dividing the ? clock. the sampling frequency is set with the nesel bit in lpwrcr. for details, see section 24.2.2, low-power control register (lpwrcr). the clock is not sampled in subactive mode, subsleep mode, or watch mode.
677 section 24 power-down state 24.1 overview in addition to the normal program execution state, the h8s/2148 series and h8s/2144 series have a power-down state in which operation of the cpu and oscillator is halted and power dissipation is reduced. low-power operation can be achieved by individually controlling the cpu, on-chip supporting modules, and so on. the h8s/2148 series and h8s/2144 series operating modes are as follows: 1. high-speed mode 2. medium-speed mode 3. subactive mode 4. sleep mode 5. subsleep mode 6. watch mode 7. module stop mode 8. software standby mode 9. hardware standby mode of these, 2 to 9 are power-down modes. sleep mode and subsleep mode are cpu modes, medium-speed mode is a cpu and bus master mode, subactive mode is a cpu, bus master, and on-chip supporting module mode, and module stop mode is an on-chip supporting module mode (including bus masters other than the cpu). certain combinations of these modes can be set. after a reset, the mcu is in high-speed mode and module stop mode (excluding the dtc). table 24.1 shows the internal chip states in each mode, and table 24.2 shows the conditions for transition to the various modes. figure 24.1 shows a mode transition diagram.
678 table 24.1 h8s/2148 series and h8s/2144 series internal states in each mode function high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby system clock oscillator function- ing function- ing function- ing function- ing halted halted halted halted halted subclock input function- ing function- ing function- ing function- ing function- ing function- ing function- ing halted halted cpu operation instruc- tions function- ing medium- speed halted function- ing halted subclock operation halted halted halted registers retained retained retained retained undefined external interrupts nmi function- ing function- ing function- ing function- ing function- ing function- ing function- ing function- ing halted irq0 irq1 irq2 on-chip supporting module dtc function- ing medium- speed function- ing function- ing/halted (retained) halted (retained) halted (retained) halted (retained) halted (retained) halted (reset) operation wdt1 function- ing function- ing function- ing function- ing subclock operation subclock operation subclock operation halted (retained) halted (reset) wdt0 halted tmr0, 1 function- ing/halted (retained) frt (retained) halted halted tmrx, y (retained) (retained) timer connec- tion iic0 iic1 sci0 function- ing/halted halted (reset) halted (reset) halted (reset) halted (reset) sci1 (reset) sci2 pwm pwmx hif, ps2 d/a a/d ram function- ing function- ing function- ing (dtc) function- ing retained function- ing retained retained retained i/o function- ing function- ing function- ing function- ing retained function- ing retained retained high impedance note: halted (retained) means that internal register values are retained. the internal state is operation suspended. halted (reset) means that internal register values and internal states are initialized. in module stop mode, only modules for which a stop setting has been made are halted (reset or retained).
679 hardware standby mode stby pin = low notes: when a transition is made between modes by means of an interrupt, transition cannot be made on interrupt source generation alone. ensure that interrupt handling is performed after accepting the interrupt request. ? from any state except hardware standby mode, a transition to the reset state occurs whenever res goes low. ? from any state, a transition to hardware standby mode occurs when stby goes low. ? when a transition is made to watch mode or subactive mode, high-speed mode must be set. sleep mode (main clock) ssby = 0, lson = 0 software standby mode ssby = 1 pss = 0, lson = 0 watch mode (subclock) ssby = 1 pss = 1, dton = 0 subsleep mode (subclock) ssby = 0 pss = 1, lson = 1 medium-speed mode (main clock) subactive mode (subclock) high-speed mode (main clock) reset state stby pin = high res pin = low res pin = high program execution state sleep instruction ssby = 1, pss = 1, dton = 1, lson = 0 clock switching exception handling after oscillation setting time (sts2 to sts0) sleep instruction ssby = 1, pss = 1, dton = 1, lson = 1 clock switching exception handling sck2 to sck0 1 0 sck2 to sck0 = 0 program-halted state sleep instruction any interrupt * 3 sleep instruction external interrupt * 4 sleep instruction interrupt * 1 , lson bit = 0 sleep instruction interrupt * 1 , lson bit = 1 interrupt * 2 sleep instruction : transition after exception handling : power-down mode * 1 nmi, irq0 to irq2, irq6, irq7, and wdt1 interrupts * 2 nmi, irq0 to irq7, and wdt0 interrupts, wdt1 interrupt, tmr0 interrupt, tmr1 interrupt * 3 all interrupts * 4 nmi, irq0 to irq2, irq6, irq7 figure 24.1 mode transitions
680 table 24.2 power-down mode transition conditions control bit states at time of transition state before transition ssby pss lson dton state after transition by sleep instruction state after return by interrupt high-speed/ medium-speed 0 * 0 * sleep high-speed/ medium-speed 0 * 1 * 100 * software standby high-speed/ medium-speed 101 * 1 1 0 0 watch high-speed 1 1 1 0 watch subactive 1101 1111subactive subactive 0 0 ** 010 * 011 * subsleep subactive 10 ** 1 1 0 0 watch high-speed 1 1 1 0 watch subactive 1 1 0 1 high-speed 1111 * : dont care : do not set. 24.1.1 register configuration the power-down state is controlled by the sbycr, lpwrcr, tcsr (wdt1), and mstpcr registers. table 24.3 summarizes these registers. table 24.3 power-down state registers name abbreviation r/w initial value address * standby control register sbycr r/w h'00 h'ff84 low-power control register lpwrcr r/w h'00 h'ff85 timer control/status register (wdt1) tcsr r/w h'00 h'ffea module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 note: * lower 16 bits of the address.
681 24.2 register descriptions 24.2.1 standby control register (sbycr) 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 ? 0 0 sck0 0 r/w 2 sck2 0 r/w 1 sck1 0 r/w bit initial value read/write sbycr is an 8-bit readable/writable register that performs power-down mode control. sbycr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7software standby (ssby): determines the operating mode, in combination with other control bits, when a power-down mode transition is made by executing a sleep instruction. the ssby setting is not changed by a mode transition due to an interrupt, etc. bit 7 ssby description 0 transition to sleep mode after execution of sleep instruction in high-speed mode or medium-speed mode transition to subsleep mode after execution of sleep instruction in subactive mode (initial value) 1 transition to software standby mode, subactive mode, or watch mode after execution of sleep instruction in high-speed mode or medium-speed mode transition to watch mode or high-speed mode after execution of sleep instruction in subactive mode
682 bits 6 to 4standby timer select 2 to 0 (sts2 to sts0): these bits select the time the mcu waits for the clock to stabilize when software standby mode, watch mode, or subactive mode is cleared and a transition is made to high-speed mode or medium-speed mode by means of a specific interrupt or instruction. with crystal oscillation, refer to table 24.4 and make a selection according to the operating frequency so that the standby time is at least 8 ms (the oscillation settling time). with an external clock, any selection can be made. bit 6 bit 5 bit 4 sts2 sts1 sts0 description 0 0 0 standby time = 8192 states (initial value) 1 standby time = 16384 states 1 0 standby time = 32768 states 1 standby time = 65536 states 1 0 0 standby time = 131072 states 1 standby time = 262144 states 1 0 reserved 1 standby time = 16 states * note: * this setting must not be used in the flash memory version. bit 3reserved: this bit cannot be modified and is always read as 0. bits 2 to 0system clock select (sck2 to sck0): these bits select the clock for the bus master in high-speed mode and medium-speed mode. when operating the device after a transition to subactive mode or watch mode, bits sck2 to sck0 should all be cleared to 0. bit 2 bit 1 bit 0 sck2 sck1 sck0 description 0 0 0 bus master is in high-speed mode (initial value) 1 medium-speed clock is ?/2 1 0 medium-speed clock is ?/4 1 medium-speed clock is ?/8 1 0 0 medium-speed clock is ?/16 1 medium-speed clock is ?/32 1
683 24.2.2 low-power control register (lpwrcr) 7 dton 0 r/w 6 lson 0 r/w 5 nesel 0 r/w 4 excle 0 r/w 3 ? 0 0 ? 0 2 ? 0 1 ? 0 bit initial value read/write lpwrcr is an 8-bit readable/writable register that performs power-down mode control. lpwrcr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7direct-transfer on flag (dton): specifies whether a direct transition is made between high-speed mode, medium-speed mode, and subactive mode when making a power- down transition by executing a sleep instruction. the operating mode to which the transition is made after sleep instruction execution is determined by a combination of other control bits. bit 7 dton description 0 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, software standby mode, or watch mode * when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode or watch mode (initial value) 1 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made directly to subactive mode * , or a transition is made to sleep mode or software standby mode when a sleep instruction is executed in subactive mode, a transition is made directly to high-speed mode, or a transition is made to subsleep mode note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set.
684 bit 6low-speed on flag (lson): determines the operating mode in combination with other control bits when making a power-down transition by executing a sleep instruction. also controls whether a transition is made to high-speed mode or to subactive mode when watch mode is cleared. bit 6 lson description 0 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, software standby mode, or watch mode * when a sleep instruction is executed in subactive mode, a transition is made to watch mode, or directly to high-speed mode after watch mode is cleared, a transition is made to high-speed mode (initial value) 1 when a sleep instruction is executed in high-speed mode a transition is made to watch mode or subactive mode * when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode or watch mode after watch mode is cleared, a transition is made to subactive mode note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set. bit 5noise elimination sampling frequency select (nesel): selects the frequency at which the subclock (?sub) input from the excl pin is sampled with the clock (?) generated by the system clock oscillator. when ? = 5 mhz or higher, clear this bit to 0. bit 5 nesel description 0 sampling at ? divided by 32 (initial value) 1 sampling at ? divided by 4 bit 4subclock input enable (excle): controls subclock input from the excl pin. bit 4 excle description 0 subclock input from excl pin is disabled (initial value) 1 subclock input from excl pin is enabled bits 3 to 0reserved: these bits cannot be modified and are always read as 0.
685 24.2.3 timer control/status register (tcsr) tcsr1 7 ovf 0 r/(w) * 6 wt/ it 0 r/w 5 tme 0 r/w 4 pss 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write note: * only 0 can be written in bit 7, to clear the flag. tcsr1 is an 8-bit readable/writable register that performs selection of the wdt1 tcnt input clock, mode, etc. only bit 4 is described here. for details of the other bits, see section 14.2.2, timer control/status register (tcsr). tcsr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 4prescaler select (pss): selects the wdt1 tcnt input clock. this bit also controls the operation in a power-down mode transition. the operating mode to which a transition is made after execution of a sleep instruction is determined in combination with other control bits. for details, see the description of clock select 2 to 0 in section 14.2.2, timer control/status register (tcsr). bit 4 pss description 0 tcnt counts ?-based prescaler (psm) divided clock pulses when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode or software standby mode (initial value) 1 tcnt counts ?sub-based prescaler (psm) divided clock pulses when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, watch mode * , or subactive mode * when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode, watch mode, or high-speed mode note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set.
686 24.2.4 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers that perform module stop mode control. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstrcrh and mstpcrl bits 7 to 0module stop (mstp 15 to mstp 0): these bits specify module stop mode. see table 24.3 for the method of selecting on-chip supporting modules. mstpcrh, mstpcrl bits 7 to 0 mstp15 to mstp0 description 0 module stop mode is cleared (initial value of mstp15, mstp14) 1 module stop mode is set (initial value of mstp13 to mstp0)
687 24.3 medium-speed mode when the sck2 to sck0 bits in sbycr are set to 1 in high-speed mode, the operating mode changes to medium-speed mode at the end of the bus cycle. in medium-speed mode, the cpu operates on the operating clock (?/2, ?/4, ?/8, ?/16, or ?/32) specified by the sck2 to sck0 bits. the bus master other than the cpu (the dtc) also operates in medium-speed mode. on-chip supporting modules other than the bus masters always operate on the high-speed clock (?). in medium-speed mode, a bus access is executed in the specified number of states with respect to the bus master operating clock. for example, if ?/4 is selected as the operating clock, on-chip memory is accessed in 4 states, and internal i/o registers in 8 states. medium-speed mode is cleared by clearing all of bits sck2 to sck0 to 0. a transition is made to high-speed mode and medium-speed mode is cleared at the end of the current bus cycle. if a sleep instruction is executed when the ssby bit in sbycr and the lson bit in lpwrcr are cleared to 0, a transition is made to sleep mode. when sleep mode is cleared by an interrupt, medium-speed mode is restored. if a sleep instruction is executed when the ssby bit in sbycr is set to 1, and the lson bit in lpwrcr and the pss bit in tcsr (wdt1) are both cleared to 0, a transition is made to software standby mode. when software standby mode is cleared by an external interrupt, medium-speed mode is restored. when the 5(6 pin is driven low, a transition is made to the reset state, and medium-speed mode is cleared. the same applies in the case of a reset caused by overflow of the watchdog timer. when the 67%< pin is driven low, a transition is made to hardware standby mode. figure 24.2 shows the timing for transition to and clearance of medium-speed mode. bus master clock ? supporting module clock internal address bus internal write signal medium-speed mode sbycr sbycr figure 24.2 medium-speed mode transition and clearance timing
688 24.4 sleep mode 24.4.1 sleep mode if a sleep instruction is executed when the ssby bit in sbycr and the lson bit in lpwrcr are both cleared to 0, the cpu enters sleep mode. in sleep mode, cpu operation stops but the contents of the cpus internal registers are retained. other supporting modules do not stop. 24.4.2 clearing sleep mode sleep mode is cleared by any interrupt, or with the 5(6 pin or 67%< pin. clearing with an interrupt: when an interrupt request signal is input, sleep mode is cleared and interrupt exception handling is started. sleep mode will not be cleared if interrupts are disabled, or if interrupts other than nmi have been masked by the cpu. clearing with the 5(6 5(6 pin: when the 5(6 pin is driven low, the reset state is entered. when the 5(6 pin is driven high after the prescribed reset input period, the cpu begins reset exception handling. clearing with the 67%< 67%< pin: when the 67%< pin is driven low, a transition is made to hardware standby mode. 24.5 module stop mode 24.5.1 module stop mode module stop mode can be set for individual on-chip supporting modules. when the corresponding mstp bit in mstpcr is set to 1, module operation stops at the end of the bus cycle and a transition is made to module stop mode. the cpu continues operating independently. table 24.4 shows mstp bits and the corresponding on-chip supporting modules. when the corresponding mstp bit is cleared to 0, module stop mode is cleared and the module starts operating again at the end of the bus cycle. in module stop mode, the internal states of modules other than the sci, a/d converter, 8-bit pwm module, and 14-bit pwm module, are retained. after reset release, all modules other than the dtc are in module stop mode.
689 when an on-chip supporting module is in module stop mode, read/write access to its registers is disabled. table 24.4 mstp bits and corresponding on-chip supporting modules register bit module mstpcrh mstp15 mstp14 * data transfer controller (dtc) mstp13 16-bit free-running timer (frt) mstp12 8-bit timers (tmr0, tmr1) mstp11 8-bit pwm timer (pwm), 14-bit pwm timer (pwmx) mstp10 d/a converter mstp9 a/d converter mstp8 8-bit timers (tmrx, tmry), timer connection mstpcrl mstp7 serial communication interface 0 (sci0) mstp6 serial communication interface 1 (sci1) mstp5 serial communication interface 2 (sci2) mstp4 * i 2 c bus interface (iic) channel 0 (option) mstp3 * i 2 c bus interface (iic) channel 1 (option) mstp2 * host interface (hif), keyboard buffer controller (ps2) mstp1 * mstp0 * note: bits 1 and 0 can be read or written to, but do not affect operation. * must be set to 1 in the h8s/2144 series. 24.5.2 usage note if there is conflict between dtc module stop mode setting and a dtc bus request, the bus request has priority and the mstp bit will not be set to 1. write 1 to the mstp bit again after the dtc bus cycle. when using an h8s/2144 series mcu, the mstp bits for nonexistent modules must be set to 1.
690 24.6 software standby mode 24.6.1 software standby mode if a sleep instruction is executed when the ssby bit in sbycr is set to 1, the lson bit in lpwrcr is cleared to 0, and the pss bit in tcsr (wdt1) is cleared to 0, software standby mode is entered. in this mode, the cpu, on-chip supporting modules, and oscillator all stop. however, the contents of the cpus internal registers, ram data, and the states of on-chip supporting modules other than the sci, pwm, and pwmx, and of the i/o ports, are retained. in this mode the oscillator stops, and therefore power dissipation is significantly reduced. 24.6.2 clearing software standby mode software standby mode is cleared by an external interrupt (nmi pin, or pin ,54 , ,54 , ,54 , ,54 , or ,54 ), or by means of the 5(6 pin or 67%< pin. clearing with an interrupt: when an nmi, irq0, irq1, irq2, irq6, or irq7 interrupt request signal is input, clock oscillation starts, and after the elapse of the time set in bits sts2 to sts0 in syscr, stable clocks are supplied to the entire chip, software standby mode is cleared, and interrupt exception handling is started. software standby mode cannot be cleared with an irq0, irq1, irq2, irq6, or irq7 interrupt if the corresponding enable bit has been cleared to 0 or has been masked by the cpu. clearing with the 5(6 5(6 pin: when the 5(6 pin is driven low, clock oscillation is started. at the same time as clock oscillation starts, clocks are supplied to the entire chip. note that the 5(6 pin must be held low until clock oscillation stabilizes. when the 5(6 pin goes high, the cpu begins reset exception handling. clearing with the 67%< 67%< pin: when the 67%< pin is driven low, a transition is made to hardware standby mode.
691 24.6.3 setting oscillation settling time after clearing software standby mode bits sts2 to sts0 in sbycr should be set as described below. using a crystal oscillator: set bits sts2 to sts0 so that the standby time is at least 8 ms (the oscillation settling time). table 24.5 shows the standby times for different operating frequencies and settings of bits sts2 to sts0. table 24.5 oscillation settling time settings sts2 sts1 sts0 standby time 20 mhz 16 mhz 12 mhz 10 mhz 8 mhz 6 mhz 4 mhz 2 mhz unit 0 0 0 8192 states 0.41 0.51 0.65 0.8 1.0 1.3 2.0 4.1 ms 1 16384 states 0.82 1.0 1.3 1.6 2.0 2.7 4.1 8.2 1 0 32768 states 1.6 2.0 2.7 3.3 4.1 5.5 8.2 16.4 1 65536 states 3.3 4.1 5.5 6.6 8.2 10.9 16.4 32.8 1 0 0 131072 states 6.6 8.2 10.9 13.1 16.4 21.8 32.8 65.5 1 262144 states 13.1 16.4 21.8 26.2 32.8 43.6 65.6 131.2 1 0 reserved s 1 16 states * 0.8 1.0 1.3 1.6 2.0 2.7 4.0 8.0 : recommended time setting * : dont care note: * this setting must not be used in the flash memory version. using an external clock: any value can be set. normally, use of the minimum time is recommended.
692 24.6.4 software standby mode application example figure 24.3 shows an example in which a transition is made to software standby mode at the falling edge on the nmi pin, and software standby mode is cleared at the rising edge on the nmi pin. in this example, an nmi interrupt is accepted with the nmieg bit in syscr cleared to 0 (falling edge specification), then the nmieg bit is set to 1 (rising edge specification), the ssby bit is set to 1, and a sleep instruction is executed, causing a transition to software standby mode. software standby mode is then cleared at the rising edge on the nmi pin. oscillator nmi nmieg ssby nmi exception handling nmieg = 1 ssby = 1 sleep instruction software standby mode (power-down state) oscillation settling time t osc2 nmi exception handling figure 24.3 software standby mode application example
693 24.6.5 usage note in software standby mode, i/o port states are retained. therefore, there is no reduction in current dissipation for the output current when a high-level signal is output. current dissipation increases while waiting for oscillation to settle. 24.7 hardware standby mode 24.7.1 hardware standby mode when the 67%< pin is driven low, a transition is made to hardware standby mode from any mode. in hardware standby mode, all functions enter the reset state and stop operation, resulting in a significant reduction in power dissipation. as long as the prescribed voltage is supplied, on-chip ram data is retained. i/o ports are set to the high-impedance state. in order to retain on-chip ram data, the rame bit in syscr should be cleared to 0 before driving the 67%< pin low. do not change the state of the mode pins (md1 and md0) while the chip is in hardware standby mode. hardware standby mode is cleared by means of the 67%< pin and the 5(6 pin. when the 67%< pin is driven high while the 5(6 pin is low, the reset state is set and clock oscillation is started. ensure that the 5(6 pin is held low until the clock oscillation settles (at least 8 msthe oscillation settling timewhen using a crystal oscillator). when the 5(6 pin is subsequently driven high, a transition is made to the program execution state via the reset exception handling state.
694 24.7.2 hardware standby mode timing figure 24.4 shows an example of hardware standby mode timing. when the 67%< pin is driven low after the 5(6 pin has been driven low, a transition is made to hardware standby mode. hardware standby mode is cleared by driving the 67%< pin high, waiting for the oscillation settling time, then changing the 5(6 pin from low to high. oscillator res stby oscillation settling time reset exception handling figure 24.4 hardware standby mode timing 24.8 watch mode 24.8.1 watch mode if a sleep instruction is executed in high-speed mode or subactive mode when the ssby in sbycr is set to 1, the dton bit in lpwrcr is cleared to 0, and the pss bit in tcsr (wdt1) is set to 1, the cpu makes a transition to watch mode. in this mode, the cpu and all on-chip supporting modules except wdt1 stop. as long as the prescribed voltage is supplied, the contents of some of the cpus internal registers and on-chip ram are retained, and i/o ports retain their states prior to the transition.
695 24.8.2 clearing watch mode watch mode is cleared by an interrupt (wovi1 interrupt, nmi pin, or pin ,54 , ,54 , ,54 , ,54 , or ,54 ), or by means of the 5(6 pin or 67%< pin. clearing with an interrupt: when an interrupt request signal is input, watch mode is cleared and a transition is made to high-speed mode or medium-speed mode if the lson bit in lpwrcr is cleared to 0, or to subactive mode if the lson bit is set to 1. when making a transition to high-speed mode, after the elapse of the time set in bits sts2 to sts0 in sbycr, stable clocks are supplied to the entire chip, and interrupt exception handling is started. watch mode cannot be cleared with an irq0, irq1, irq2, irq6, or irq7 interrupt if the corresponding enable bit has been cleared to 0, or with an on-chip supporting module interrupt if acceptance of the relevant interrupt has been disabled by the interrupt enable register or masked by the cpu. see section 24.6.3, setting oscillation settling time after clearing software standby mode, for the oscillation settling time setting when making a transition from watch mode to high-speed mode. clearing with the 5(6 5(6 pin: see clearing with the 5(6 pin in section 24.6.2, clearing software standby mode. clearing with the 67%< 67%< pin: when the 67%< pin is driven low, a transition is made to hardware standby mode. 24.9 subsleep mode 24.9.1 subsleep mode if a sleep instruction is executed in subactive mode when the ssby in sbycr is cleared to 0, the lson bit in lpwrcr is set to 1, and the pss bit in tcsr (wdt1) is set to 1, the cpu makes a transition to subsleep mode. in this mode, the cpu and all on-chip supporting modules except tmr0, tmr1, wdt0, and wdt1 stop. as long as the prescribed voltage is supplied, the contents of some of the cpus internal registers and on-chip ram are retained, and i/o ports retain their states prior to the transition.
696 24.9.2 clearing subsleep mode subsleep mode is cleared by an interrupt (on-chip supporting module interrupt, nmi pin, or pin ,54 to ,54 ), or by means of the 5(6 pin or 67%< pin. clearing with an interrupt: when an interrupt request signal is input, subsleep mode is cleared and interrupt exception handling is started. subsleep mode cannot be cleared with an irq0 to irq7 interrupt if the corresponding enable bit has been cleared to 0, or with an on-chip supporting module interrupt if acceptance of the relevant interrupt has been disabled by the interrupt enable register or masked by the cpu. clearing with the 5(6 5(6 pin: see clearing with the 5(6 pin in section 24.6.2, clearing software standby mode. clearing with the 67%< 67%< pin: when the 67%< pin is driven low, a transition is made to hardware standby mode 24.10 subactive mode 24.10.1 subactive mode if a sleep instruction is executed in high-speed mode when the ssby bit in sbycr, the dton bit in lpwrcr, and the pss bit in tcsr (wdt1) are all set to 1, the cpu makes a transition to subactive mode. when an interrupt is generated in watch mode, if the lson bit in lpwrcr is set to 1, a transition is made to subactive mode. when an interrupt is generated in subsleep mode, a transition is made to subactive mode. in subactive mode, the cpu performs sequential program execution at low speed on the subclock. in this mode, all on-chip supporting modules except tmr0, tmr1, wdt0, and wdt1 stop. when operating the device in subactive mode, bits sck2 to sck0 in sbycr must all be cleared to 0.
697 24.10.2 clearing subactive mode subsleep mode is cleared by a sleep instruction, or by means of the 5(6 pin or 67%< pin. clearing with a sleep instruction: when a sleep instruction is executed while the ssby bit in sbycr is set to 1, the dton bit in lpwrcr is cleared to 0, and the pss bit in tcsr (wdt1) is set to 1, subactive mode is cleared and a transition is made to watch mode. when a sleep instruction is executed while the ssby bit in sbycr is cleared to 0, the lson bit in lpwrcr is set to 1, and the pss bit in tcsr (wdt1) is set to 1, a transition is made to subsleep mode. when a sleep instruction is executed while the ssby bit in sbycr is set to 1, the dton bit is set to 1 and the lson bit is cleared to 0 in lpwrcr, and the pss bit in tcsr (wdt1) is set to 1, a transition is made directly to high-speed mode. fort details of direct transition, see section 24.11, direct transition. clearing with the 5(6 5(6 pin: see clearing with the 5(6 pin in section 24.6.2, clearing software standby mode. clearing with the 67%< 67%< pin: when the 67%< pin is driven low, a transition is made to hardware standby mode 24.11 direct transition 24.11.1 overview of direct transition there are three operating modes in which the cpu executes programs: high-speed mode, medium-speed mode, and subactive mode. a transition between high-speed mode and subactive mode without halting the program is called a direct transition. a direct transition can be carried out by setting the dton bit in lpwrcr to 1 and executing a sleep instruction. after the transition, direct transition interrupt exception handling is started. direct transition from high-speed mode to subactive mode: if a sleep instruction is executed in high-speed mode while the ssby bit in sbycr, the lson bit and dton bit in lpwrcr, and the pss bit in tscr (wdt1) are all set to 1, a transition is made to subactive mode. direct transition from subactive mode to high-speed mode: if a sleep instruction is executed in subactive mode while the ssby bit in sbycr is set to 1, the lson bit is cleared to 0 and the dton bit is set to 1 in lpwrcr, and the pss bit in tscr (wdt1) is set to 1, after the elapse of the time set in bits sts2 to sts0 in sbycr, a transition is made to directly to high-speed mode.
698
699 section 25 electrical characteristics 25.1 absolute maximum ratings table 25.1 lists the absolute maximum ratings. the h8s/2144 series does not support the vccb pin function, so v cc b should be read as v cc in the tables for this series. table 25.1 absolute maximum ratings C preliminary C item symbol value unit power supply voltage v cc C0.3 to +7.0 v input voltage (except ports 6, 7, and a) v in C0.3 to v cc +0.3 v input voltage (cin input not selected for port 6) v in C0.3 to v cc +0.3 v input voltage (cin input not selected for port a) v in C0.3 to v cc b +0.3 v input voltage (cin input selected for port 6) v in C0.3 v to lower of voltages v cc + 0.3 and av cc + 0.3 v input voltage (cin input selected for port a) v in C0.3 v to lower of voltages v cc b + 0.3 and av cc + 0.3 v input voltage (port 7) v in C0.3 to av cc + 0.3 v reference supply voltage av ref C0.3 to av cc + 0.3 v analog power supply voltage av cc C0.3 to +7.0 v analog input voltage v an C0.3 to av cc +0.3 v operating temperature t opr regular specifications: C20 to +75 c wide-range specifications: C40 to +85 c operating temperature (flash t opr regular specifications: 0 to +75 c memory programming/erasing) wide-range specifications: 0 to +85 c storage temperature t stg C55 to +125 c caution: permanent damage to the chip may result if absolute maximum ratings are exceeded.
700 25.2 dc characteristics table 25.2 lists the dc characteristics. permitted output current values and bus drive characteristics are shown in tables 25.3 and 25.4, respectively. the h8s/2144 series does not support the vccb pin function, so v cc b should be read as v cc in the tables for this series. table 25.2 dc characteristics (1) C preliminary C conditions: v cc = 5.0 v 10%, v cc b = 5.0 v 10%, av cc * 1 = 5.0 v 10%, av ref * 1 = 4.5 v to av cc , v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 (regular specifications), t a = C40 to +85c* 11 (wide-range specifications) item symbol min typ max unit test conditions schmitt trigger input p67 to p60 * 2, * 6 , .,1 to .,1 * 7 , (1) * 8 v t C 1.0 v voltage ,54 to ,54 * 3 , ,54 to ,54 v t + v cc 0.7 v cc b 0.7 v v t + C v t C 0.4 v schmitt trigger input p67 to p60 (kwul = 00) v t C 1.0 v h8s/2148 series only voltage (in level v t + v cc 0.7 switching) * 6 v t + C v t C 0.4 p67 to p60 v t C v cc 0.3 (kwul = 01) v t + v cc 0.7 v t + C v t C v cc 0.05 p67 to p60 v t C v cc 0.4 (kwul = 10) v t + v cc 0.8 v t + C v t C v cc 0.03 p67 to p60 v t C v cc 0.45 (kwul = 11) v t + v cc 0.9 v t + C v t C 0.05
701 table 25.2 dc characteristics (1) (cont) C preliminary C conditions: v cc = 5.0 v 10%, v cc b = 5.0 v 10%, av cc * 1 = 5.0 v 10%, av ref * 1 = 4.5 v to av cc , v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 (regular specifications), t a = C40 to +85c* 11 (wide-range specifications) item symbol min typ max unit test conditions input high voltage 5(6 , 67%< , nmi, md1, md0 (2) v ih v cc C 0.7 v cc +0.3 v extal v cc 0.7 v cc +0.3 v pa7 to pa0 * 7 v cc b 0.7 v cc b +0.3 v port 7 2.0 av cc +0.3 v input pins except (1) and (2) above 2.0 v cc +0.3 v input low voltage 5(6 , 67%< , md1, md0 (3) v il C0.3 0.5 v pa7 to pa0 C0.3 1.0 v nmi, extal, input pins except (1) and (3) above C0.3 0.8 v output high voltage all output pins (except p97, and v oh v cc C0.5 v cc b C0.5 v i oh = C200 a p52 * 4 ) * 5, * 8 3.5 v i oh = C1 ma p97, p52 * 4 2.5 v i oh = C1 ma output low voltage all output pins (except 5(62 ) * 5 v ol 0.4 v i ol = 1.6 ma ports 1 to 3 1.0 v i ol = 10 ma 5(62 0.4 v i ol = 2.6 ma input leakage 5(6 w i in w 10.0 a v in = 0.5 to v cc C 0.5 v current 67%< , nmi, md1, md0 1.0 a port 7 1.0 a v in = 0.5 to av cc C 0.5 v
702 table 25.2 dc characteristics (1) (cont) C preliminary C conditions: v cc = 5.0 v 10%, v cc b = 5.0 v 10%, av cc * 1 = 5.0 v 10%, av ref * 1 = 4.5 v to av cc , v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 (regular specifications), t a = C40 to +85c* 11 (wide-range specifications) item symbol min typ max unit test conditions three-state leakage current (off state) ports 1 to 6 ports 8, 9, a * 8 , b w i tsi w 1.0 a v in = 0.5 to v cc C 0.5 v, v in = 0.5 to v cc b C 0.5 v input pull-up ports 1 to 3 Ci p 50 300 a v in = 0 v mos current ports 6, a * 8 , b 60 500 a port 6 (p6pue = 0) 60 500 a v in = 0 v h8s/2148 port 6 (p6pue = 1) 15 150 a series only input capacitance 5(6 (4) c in 80 pfv in = 0 v f = 1 mhz nmi 50 pf t a = 25c p52, p97, p42, p86 pa7 to pa2 20 pf input pins except (4) above 15 pf current dissipation * 9 normal operation i cc 75 100 ma f = 20 mhz, h8s/2144 series 85 120 ma f = 20 mhz, h8s/2148 series sleep mode 60 85 ma f = 20 mhz, h8s/2144 series 70 100 ma f = 20 mhz, h8s/2148 series standby mode * 10 0.01 5.0 a t a 50c 20.0 a 50c < t a
703 table 25.2 dc characteristics (1) (cont) C preliminary C conditions: v cc = 5.0 v 10%, v cc b = 5.0 v 10%, av cc * 1 = 5.0 v 10%, av ref * 1 = 4.5 v to av cc , v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 (regular specifications), t a = C40 to +85c* 11 (wide-range specifications) item symbol min typ max unit test conditions analog power during a/d, d/a conversion al cc 1.2 2.0 ma supply current idle 0.01 5.0 a av cc = 2.0 v to 5.5 v reference power during a/d conversion al ref 0.5 1.0 ma supply current during a/d, d/a conversion 2.0 5.0 ma idle 0.01 5.0 a av ref = 2.0 v to av cc analog power supply voltage * 1 av cc 4.5 5.5 v operating 2.0 5.5 v idle/not used ram standby voltage v ram 2.0 v notes: 1. do not leave the avcc, av ref , and avss pins open even if the a/d converter and d/a converter are not used. even if the a/d converter and d/a converter are not used, apply a value in the range 2.0 v to 5.5 v to avcc and av ref pins by connection to the power supply (v cc ), or some other method. ensure that av ref av cc . 2. p67 to p60 include supporting module inputs multiplexed on those pins. 3. ,54 includes the $'75* signal multiplexed on that pin. 4. in the h8s/2148 series, p52/sck0/scl0 and p97/sda0 are nmos push-pull outputs. an external pull-up resistor is necessary to provide high-level output from scl0 and sda0 (ice = 1). in the h8s/2148 series, p52/sck0 and p97 (ice = 0) high levels are driven by nmos. 5. when iics = 0, ice = 0, and kbioe = 0. low-level output when the bus drive function is selected is determined separately. 6. the upper limit of the port 6 applied voltage is v cc + 0.3 v when cin input is not selected, and the lower of v cc + 0.3 v and av cc + 0.3 v when cin input is selected. when a pin is in output mode, the output voltage is equivalent to the applied voltage. 7. the upper limit of the port a applied voltage is v cc b + 0.3 v when cin input is not selected, and the lower of v cc b + 0.3 v and av cc + 0.3 v when cin input is selected. when a pin is in output mode, the output voltage is equivalent to the applied voltage. 8. port a characteristics depends on v cc b (or on v cc when other pins are in output mode). 9. current dissipation values are for v ih min = v cc C 0.5 v, v cc b C 0.5 v, and v il max = 0.5 v with all output pins unloaded and the on-chip pull-up moss in the off state. 10. the values are for v ram v cc < 4.5v, v ih min = v cc 0.9, v cc b 0.9, and v il max = 0.3 v. 11. for flash memory program/erase operations, the applicable range is t a = 0 to +75c (regular specifications) or t a = 0 to +85c (wide-range specifications).
704 table 25.2 dc characteristics (2) C preliminary C conditions:v cc = 4.0 v to 5.5 v* 11 , v cc b = 4.0 v to 5.5 v, av cc * 1 = 4.0 v to 5.5 v, av ref * 1 = 4.0 v to av cc , v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 (regular specifications), t a = C40 to +85c* 11 (wide-range specifications) item symbol min typ max unit test conditions schmitt trigger input p67 to p60 * 2, * 6 , .,1 to .,1 * 7 , (1) * 8 v t C 1.0 v v cc = 4.5 v to 5.5 v, voltage ,54 to ,54 * 3 , ,54 to ,54 v t + v cc 0.7 v cc b 0.7 v v cc b = 4.5 v to 5.5 v v t + C v t C 0.4 v v t C 0.8 v v cc = 4.0 v to 4.5 v, v t + v cc 0.7 v cc b 0.7 v v cc b = 4.0 v to 4.5 v v t + C v t C 0.3 v schmitt trigger input p67 to p60 (kwul = 00) v t C 0.8 v h8s/2148 series only voltage (in level v t + v cc 0.7 v cc = 4.0 v to 4.5 v switching) * 6 v t + C v t C 0.3 p67 to p60 v t C v cc 0.3 (kwul = 01) v t + v cc 0.7 v t + C v t C v cc 0.05 p67 to p60 v t C v cc 0.4 (kwul = 10) v t + v cc 0.8 v t + C v t C v cc 0.03 p67 to p60 v t C v cc 0.45 (kwul = 11) v t + v cc 0.9 v t + C v t C 0.05
705 table 25.2 dc characteristics (2) (cont) C preliminary C conditions:v cc = 4.0 v to 5.5 v* 11 , v cc b = 4.0 v to 5.5 v, av cc * 1 = 4.0 v to 5.5 v, av ref * 1 = 4.0 v to av cc , v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 (regular specifications), t a = C40 to +85c* 11 (wide-range specifications) item symbol min typ max unit test conditions input high voltage 5(6 , 67%< , nmi, md1, md0 (2) v ih v cc C 0.7 v cc +0.3 v extal v cc 0.7 v cc +0.3 v pa7 to pa0 * 7 v cc b 0.7 v cc b + 0.3 v port 7 2.0 av cc +0.3 v input pins except (1) and (2) above 2.0 v cc +0.3 v input low voltage 5(6 , 67%< , md1, md0 (3) v il C0.3 0.5 v pa7 to pa0 C0.3 1.0 v v cc b = 4.5 v to 5.5 v C0.3 0.8 v v cc b = 4.0 v to 4.5 v nmi, extal, input pins except (1) and (3) above C0.3 0.8 v output high voltage all output pins (except p97, and p52 * 4 ) * 5, * 8 v oh v cc C0.5 v cc b C0.5 vi oh = C200 a 3.5 v i oh = C1 ma, v cc = 4.5 v to 5.5 v, v cc b = 4.5 v to 5.5 v 3.0 v i oh = C1 ma, v cc = 4.0 v to 4.5 v, v cc b = 4.0 v to 4.5 v p97, p52 * 4 2.0 v i oh = C1 ma
706 table 25.2 dc characteristics (2) (cont) C preliminary C conditions:v cc = 4.0 v to 5.5 v* 11 , v cc b = 4.0 v to 5.5 v, av cc * 1 = 4.0 v to 5.5 v, av ref * 1 = 4.0 v to av cc , v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 (regular specifications), t a = C40 to +85c* 11 (wide-range specifications) item symbol min typ max unit test conditions output low voltage all output pins (except 5(62 ) * 5 v ol 0.4 v i ol = 1.6 ma ports 1 to 3 1.0 v i ol = 10 ma 5(62 0.4 v i ol = 2.6 ma input 5(6 w i in w 10.0 a v in = 0.5 to leakage current 67%< , nmi, md1, md0 1.0 a v cc C 0.5 v port 7 1.0 a v in = 0.5 to av cc C 0.5 v three-state leakage current (off state) ports 1 to 6 ports 8, 9, a * 8 , b w i tsi w 1.0 a v in = 0.5 to v cc C 0.5 v, v in = 0.5 to v cc b C 0.5 v input pull-up ports 1 to 3 Ci p 50 300 a v in = 0 v, v cc = 4.5 v to 5.5 v mos current ports 6, a * 8 , b 60 500 a v cc b = 4.5 v to 5.5 v ports 1 to 3 30 200 a v in = 0 v, v cc = 4.0 v to 4.5 v, ports 6, a * 8 , b 40 400 a v cc b = 4.0 v to 4.5 v port 6 (p6pue = 0) 60 500 a v in = 0 v, v cc = 4.5 v to 5.5 v, port 6 (p6pue = 1) 15 150 a h8s/2148 series only port 6 (p6pue = 0) 40 400 a v in = 0 v, v cc = 4.0 v to 4.5 v, port 6 (p6pue = 1) 10 110 a h8s/2148 series only
707 table 25.2 dc characteristics (2) (cont) C preliminary C conditions:v cc = 4.0 v to 5.5 v* 11 , v cc b = 4.0 v to 5.5 v, av cc * 1 = 4.0 v to 5.5 v, av ref * 1 = 4.0 v to av cc , v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 (regular specifications), t a = C40 to +85c* 11 (wide-range specifications) item symbol min typ max unit test conditions input capacitance 5(6 (4) c in 80 pfv in = 0 v, f = 1 mhz, nmi 50 pf t a = 25c p52, p97, p42, p86, pa7 to pa2 20 pf input pins except (4) above 15 pf current dissipation * 9 normal operation i cc 65 85 ma f = 16 mhz, h8s/2144 series 70 100 ma f = 16 mhz, h8s/2148 series sleep mode 50 70 ma f = 16 mhz, h8s/2144 series 60 85 ma f = 16 mhz, h8s/2148 series standby mode * 10 0.01 5.0 a t a 50c 20.0 a 50c < t a analog power during a/d, d/a conversion al cc 1.2 2.0 ma supply current idle 0.01 5.0 a av cc = 2.0 v to 5.5 v reference power during a/d conversion al ref 0.5 1.0 ma supply current during a/d, d/a conversion 2.0 5.0 ma idle 0.01 5.0 a av ref = 2.0 v to av cc analog power supply voltage * 1 av cc 4.0 5.5 v operating 2.0 5.5 v idle/not used ram standby voltage v ram 2.0 v
708 notes: 1. do not leave the avcc, av ref , and avss pins open even if the a/d converter and d/a converter are not used. even if the a/d converter and d/a converter are not used, apply a value in the range 2.0 v to 5.5 v to avcc and av ref pins by connection to the power supply (v cc ), or some other method. ensure that av ref av cc . 2. p67 to p60 include supporting module inputs multiplexed on those pins. 3. ,54 includes the $'75* signal multiplexed on that pin. 4. in the h8s/2148 series, p52/sck0/scl0 and p97/sda0 are nmos push-pull outputs. an external pull-up resistor is necessary to provide high-level output from scl0 and sda0 (ice = 1). in the h8s/2148 series, p52/sck0 and p97 (ice = 0) high levels are driven by nmos. 5. when iics = 0, ice = 0, and kbioe = 0. low-level output when the bus drive function is selected is determined separately. 6. the upper limit of the port 6 applied voltage is v cc + 0.3 v when cin input is not selected, and the lower of v cc + 0.3 v and av cc + 0.3 v when cin input is selected. when a pin is in output mode, the output voltage is equivalent to the applied voltage. 7. the upper limit of the port a applied voltage is v cc b + 0.3 v when cin input is not selected, and the lower of v cc b + 0.3 v and av cc + 0.3 v when cin input is selected. when a pin is in output mode, the output voltage is equivalent to the applied voltage. 8. the port a characteristics depend on v cc b, and the other pins characteristics depend on v cc . 9. current dissipation values are for v ih min = v cc C 0.5 v, v cc b C 0.5 v, and v il max = 0.5 v with all output pins unloaded and the on-chip pull-up moss in the off state. 10. the values are for v ram v cc < 4.5 v, v ih min = v cc 0.9, v cc b 0.9, and v il max = 0.3 v. 11. for flash memory program/erase operations, the applicable ranges are v cc = 4.5 v to 5.5 v and t a = 0 to +75c (regular specifications) or t a = 0 to +85c (wide-range specifications).
709 table 25.2 dc characteristics (3) C preliminary C conditions (mask rom version):v cc = 2.7 v to 5.5 v, v cc b = 2.7 v to 5.5 v, av cc * 1 = 2.7 v to 5.5 v, av ref * 1 = 2.7 v to 5.5 v, v ss = av ss * 1 = 0 v, t a = C20 to +75c (flash memory version):v cc = 3.0 v to 5.5 v* 11 , v cc b = 3.0 v to 5.5 v, av cc * 1 = 3.0 v to 5.5 v, av ref = 3.0 v to 5.5 v, v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 item symbol min typ max unit test conditions schmitt trigger input p67 to p60 * 2, * 6 , .,1 to .,1 * 7 , (1) * 8 v t C v cc 0.2 v cc b 0.2 v voltage ,54 to ,54 * 3 , ,54 to ,54 v t + v cc 0.7 v cc b 0.7 v v t + C v t C v cc 0.05 v cc b 0.05 v schmitt trigger input p67 to p60 (kwul = 00) v t C v cc 0.2 v h8s/2148 series only voltage v t + v cc 0.7 (in level v t + C v t C v cc 0.05 swiching) * 6 p67 to p60 v t C v cc 0.3 (kwul = 01) v t + v cc 0.7 v t + C v t C v cc 0.05 p67 to p60 v t C v cc 0.4 (kwul = 10) v t + v cc 0.8 v t + C v t C v cc 0.03 p67 to p60 v t C v cc 0.45 (kwul = 11) v t + v cc 0.9 v t + C v t C 0.05 input high voltage 5(6 , 67%< , nmi, md1, md0 (2) v ih v cc 0.9 v cc +0.3 v extal v cc 0.7 v cc +0.3 v pa7 to pa0 * 7 v cc b 0.7 v cc b +0.3 v port 7 v cc 0.7 av cc +0.3 v input pins except (1) and (2) above v cc 0.7 v cc +0.3 v
710 table 25.2 dc characteristics (3) (cont) C preliminary C conditions (mask rom version):v cc = 2.7 v to 5.5 v, v cc b = 2.7 v to 5.5 v, av cc * 1 = 2.7 v to 5.5 v, av ref * 1 = 2.7 v to 5.5 v, v ss = av ss * 1 = 0 v, t a = C20 to +75c (flash memory version):v cc = 3.0 v to 5.5 v* 11 , v cc b = 3.0 v to 5.5 v, av cc * 1 = 3.0 v to 5.5 v, av ref = 3.0 v to 5.5 v, v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 item symbol min typ max unit test conditions input low voltage 5(6 , 67%< , md1, md0 (3) v il C0.3 v cc 0.1 v pa7 to pa0 C0.3 v cc b 0.2 v v cc b = 2.7 v to 4.0 v 0.8 v v cc b = 4.0 v to 5.5 v nmi, extal, input pins except C0.3 v cc 0.2 v v cc = 2.7 v to 4.0 v (1) and (3) above 0.8 v v cc = 4.0 v to 5.5 v output high voltage all output pins (except p97, v oh v cc C 0.5 v cc b C 0.5 v i oh = C200 a and p52 * 4 ) * 5, * 8 v cc C 1.0 v i oh = C1 ma (v cc = 2.7 v to 4.0 v, v cc b = 2.7 v to 4.0 v) p97, p52 * 4 1.0 v i oh = C1 ma output low voltage all output pins (except 5(62 ) * 5 v ol 0.4 v i ol = 1.6 ma ports 1 to 3 1.0 v i ol = 5 ma (v cc < 4.0 v), i ol = 10 ma (4.0 v v cc 5.5 v) 5(62 0.4 v i ol = 1.6 ma input 5(6 w i in w 10.0 a v in = 0.5 to leakage current 67%< , nmi, md1, md0 1.0 a v cc C 0.5 v port 7 1.0 a v in = 0.5 to av cc C 0.5 v
711 table 25.2 dc characteristics (3) (cont) C preliminary C conditions (mask rom version):v cc = 2.7 v to 5.5 v, v cc b = 2.7 v to 5.5 v, av cc * 1 = 2.7 v to 5.5 v, av ref * 1 = 2.7 v to 5.5 v, v ss = av ss * 1 = 0 v, t a = C20 to +75c (flash memory version):v cc = 3.0 v to 5.5 v* 11 , v cc b = 3.0 v to 5.5 v, av cc * 1 = 3.0 v to 5.5 v, av ref = 3.0 v to 5.5 v, v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 item symbol min typ max unit test conditions three-state leakage current (off state) ports 1 to 6 ports 8, 9, a * 8 , b w i tsi w 1.0 a v in = 0.5 to v cc C 0.5 v, v in = 0.5 to v cc b C 0.5 v input pull- up mos ports 1 to 3 Ci p 10 150 a v in = 0 v, v cc = 2.7 v to current ports 6, a * 8 , b 30 250 a 3.6 v, v cc b = 2.7 v to 3.6 v port 6 (p6pue = 0) 30 250 a v in = 0 v, v cc = 2.7 v to 3.6 v port 6 (p6pue = 1) 3 70 a h8s/2148 series only input capacitance 5(6 (4) c in 80 pfv in = 0 v, f = 1 mhz, nmi 50 pf t a = 25c p52, p97, p42, p86, pa7 to pa2 20 pf input pins except (4) above 15 pf current dissipation * 9 normal operation i cc 45 60 ma f = 10 mhz, h8s/2144 series 50 70 ma f = 10 mhz, h8s/2148 series
712 table 25.2 dc characteristics (3) (cont) C preliminary C conditions (mask rom version):v cc = 2.7 v to 5.5 v, v cc b = 2.7 v to 5.5 v, av cc * 1 = 2.7 v to 5.5 v, av ref * 1 = 2.7 v to 5.5 v, v ss = av ss * 1 = 0 v, t a = C20 to +75c (flash memory version):v cc = 3.0 v to 5.5 v* 11 , v cc b = 3.0 v to 5.5 v, av cc * 1 = 3.0 v to 5.5 v, av ref = 3.0 v to 5.5 v, v ss = av ss * 1 = 0 v, t a = C20 to +75c* 11 item symbol min typ max unit test conditions current dissipation * 9 sleep mode i cc 35 50 ma f = 10 mhz, h8s/2144 series 40 60 ma f = 10 mhz, h8s/2148 series standby mode * 10 0.01 5.0 a t a 50c 20.0 a 50c < t a analog power during a/d, d/a conversion al cc 1.2 2.0 ma supply current idle 0.01 5.0 a av cc = 2.0 v to 5.5 v reference power during a/d conversion al ref 0.5 1.0 ma supply current during a/d, d/a conversion 2.0 5.0 ma idle 0.01 5.0 a av ref = 2.0 v to av cc analog power supply voltage * 1 av cc 2.7 5.5 v operating 2.0 5.5 v idle/not used ram standby voltage v ram 2.0 v notes: 1. do not leave the avcc, av ref , and avss pins open even if the a/d converter and d/a converter are not used. even if the a/d converter and d/a converter are not used, apply a value in the range 2.0 v to 5.5 v to avcc and av ref pins by connection to the power supply (v cc ), or some other method. ensure that av ref av cc . 2. p67 to p60 include supporting module inputs multiplexed on those pins. 3. ,54 includes the $'75* signal multiplexed on that pin. 4. in the h8s/2148 series, p52/sck0/scl0 and p97/sda0 are nmos push-pull outputs. an external pull-up resistor is necessary to provide high-level output from scl0 and sda0 (ice = 1). in the h8s/2148 series, p52/sck0 and p97 (ice = 0) high levels are driven by nmos.
713 5. when iics = 0, ice = 0, and kbioe = 0. low-level output when the bus drive function is selected is determined separately. 6. the upper limit of the port 6 applied voltage is v cc + 0.3 v when cin input is not selected, and the lower of v cc + 0.3 v and av cc + 0.3 v when cin input is selected. when a pin is in output mode, the output voltage is equivalent to the applied voltage. 7. the upper limit of the port a applied voltage is v cc b + 0.3 v when cin input is not selected, and the lower of v cc b + 0.3 v and av cc + 0.3 v when cin input is selected. when a pin is in output mode, the output voltage is equivalent to the applied voltage. 8. the port a characteristics depend on v cc b, and the other pins characteristics depend on v cc . 9. current dissipation values are for v ih min = v cc C 0.5 v, v cc b C 0.5 v, and v il max = 0.5 v with all output pins unloaded and the on-chip pull-up moss in the off state. 10. the values are for v ram v cc < 2.7 v, v ih min = v cc 0.9, v cc b 0.9, and v il max = 0.3 v. 11. for flash memory program/erase operations, the applicable ranges are v cc = 3.0 v to 3.6 v and ta = 0 to +75_c.
714 table 25.3 permissible output currents C preliminary C conditions:v cc = 4.0 v to 5.5 v, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ta = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) item symbol min typ max unit permissible output low current (per pin) scl1, scl0, sda1, sda0, ps2ac to ps2cc, ps2ad to ps2cd, pa7 to pa4 (bus drive function selected) i ol 20ma ports 1, 2, 3 10 ma 5(62 3 ma other output pins 2 ma permissible output low current (total) total of ports 1, 2, and 3 ? i ol 80ma total of all output pins, including the above 120 ma permissible output high current (per pin) all output pins Ci oh 2 ma permissible output high current (total) total of all output pins ? Ci oh 40ma notes: 1. to protect chip reliability, do not exceed the output current values in table 25.3. 2. when driving a darlington pair or led, always insert a current-limiting resistor in the output line, as show in figures 25.1 and 25.2.
715 table 25.3 permissible output currents (cont) C preliminary C conditions:v cc = 2.7 v to 5.5 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, t a = C20 to +75c item symbol min typ max unit permissible output low current (per pin) scl1, scl0, sda1, sda0, ps2ac to ps2cc, ps2ad to ps2cd, pa7 to pa4 (bus drive function selected) i ol 10ma ports 1, 2, 3 2 ma 5(62 1 ma other output pins 1 ma permissible output low current (total) total of ports 1, 2, and 3 ? i ol 40ma total of all output pins, including the above 60ma permissible output high current (per pin) all output pins Ci oh 2 ma permissible output high current (total) total of all output pins ? Ci oh 30ma notes: 1. to protect chip reliability, do not exceed the output current values in table 25.3. 2. when driving a darlington pair or led, always insert a current-limiting resistor in the output line, as show in figures 25.1 and 25.2.
716 table 25.4 bus drive characteristics C preliminary C conditions: v cc = 2.7 v to 5.5 v, v ss = 0 v, ta = C20 to +75c applicable pins: scl1, scl0, sda1, sda0 (bus drive function selected) item symbol min typ max unit test conditions schmitt trigger input voltage v t C v cc 0.3 v v cc = 2.7 v to 5.5 v v t + v cc 0.7 v cc = 2.7 v to 5.5 v v t + C v t C v cc 0.05 v cc = 2.7 v to 5.5 v input high voltage v ih v cc 0.7 v cc + 0.5 v v cc = 2.7 v to 5.5 v input low voltage v il C0.5 v cc 0.3 v cc = 2.7 v to 5.5 v output low voltage v ol 0.8 v i ol = 16 ma, v cc = 4.5 v to 5.5 v 0.5 i ol = 8 ma 0.4 i ol = 3 ma input capacitance c in 20pfv in = 0 v, f = 1 mhz, t a = 25c three-state leakage current (off state) | i tsi | 1.0 a v in = 0.5 to v cc C 0.5 v scl, sda output fall time t of 20 + 0.1cb 250 ns v cc = 2.7 v to 5.5 v conditions: v cc = 2.7 v to 5.5 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ta = C20 to +75c applicable pins: ps2ac, ps2ad, ps2bc, ps2bd, ps2cc, ps2cd, pa7 to pa4 (bus drive function selected) item symbol min typ max unit test conditions output low voltage v ol 0.8 v i ol = 16 ma, v cc b = 4.5 v to 5.5 v 0.5 i ol = 8 ma 0.4 i ol = 3 ma
717 2 k w h8s/2148 series or h8s/2144 series chip port darlington pair figure 25.1 darlington pair drive circuit (example) 600 w h8s/2148 series or h8s/2144 series chip ports 1 to 3 led figure 25.2 led drive circuit (example) 25.3 ac characteristics figure 25.3 shows the test conditions for the ac characteristics. c chip output pin r h r l c = 30 pf: all output ports r l = 2.4 k w r h = 12 k w i/o timing test levels ? low level: 0.8 v ? high level: 2.0 v 5 v figure 25.3 output load circuit
718 25.3.1 clock timing table 25.5 shows the clock timing. the clock timing specified here covers clock (?) output and clock pulse generator (crystal) and external clock input (extal pin) oscillation settling times. for details of external clock input (extal pin and excl pin) timing, see section 23, clock pulse generator. the h8s/2144 series does not support the vccb pin function, so v cc b should be read as v cc in the tables for this series. table 25.5 clock timing C preliminary C condition a:v cc = 5.0 v 10%, v cc b = 5.0 v 10%, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b:v cc = 4.0 v to 5.5 v*, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v*, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz test item symbol min max min max min max unit conditions clock cycle time t cyc 50 500 62.5 500 100 500 ns figure 25.4 clock high pulse width t ch 17 20 30 ns figure 25.4 clock low pulse width t cl 17 20 30 ns clock rise time t cr 8 10 20 ns clock fall time t cf 8 10 20 ns oscillation settling time at reset (crystal) t osc1 10 10 20 ms figure 25.5 figure 25.6 oscillation settling time in software standby (crystal) t osc2 8 8 8 ms external clock output stabilization delay time t dext 500 500 500 s note: * for the low-voltage f-ztat version, v cc = 3.0 v to 5.5 v.
719 t ch t cyc t cf t cl t cr figure 25.4 system clock timing t osc1 t osc1 extal v cc stby res t dext t dext figure 25.5 oscillation settling timing nmi irqi (i = 0, 1, 2, 6, 7) t osc2 figure 25.6 oscillation setting timing (exiting software standby mode)
720 25.3.2 control signal timing table 25.6 shows the control signal timing. the only external interrupts that can operate on the subclock (? = 32.768 khz) are nmi and irq0, 1, 2, 6, and 7. table 25.6 control signal timing C preliminary C condition a:v cc = 5.0 v 10%, v cc b = 5.0 v 10%, v ss = 0 v, ? = 32.768 khz, 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b:v cc = 4.0 v to 5.5 v, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ? = 32.768 khz, 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v*, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ? = 32.768 khz, 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz test item symbol min max min max min max unit conditions 5(6 setup time t ress 200 200 300 ns figure 25.7 5(6 pulse width t resw 20 20 20 t cyc nmi setup time (nmi) t nmis 150 150 250 ns figure 25.8 nmi hold time (nmi) t nmih 10 10 10 nmi pulse width (exiting software standby mode) t nmiw 200 200 200 ns irq setup time ( ,54 to ,54 ) t irqs 150 150 250 ns irq hold time ( ,54 to ,54 ) t irqh 10 10 10 ns irq pulse width ( ,54 , ,54 , ,54 to ,54 ) (exiting software standby mode) t irqw 200 200 200 ns note: * for the low-voltage f-ztat version, v cc = 3.0 v to 5.5 v.
721 t resw t ress t ress res figure 25.7 reset input timing t irqs t nmis t nmih irq edge input nmi t irqs t irqh irqi (i = 7 to 0) irq level input t nmiw t irqw figure 25.8 interrupt input timing
722 25.3.3 bus timing table 25.7 shows the bus timing. operation in external expansion mode is not guaranteed when operating on the subclock (? = 32.768 khz). table 25.7 bus timing C preliminary C condition a:v cc = 5.0 v 10%, v cc b = 5.0 v 10%, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b:v cc = 4.0 v to 5.5 v, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v*, v cc b = 2.7 v to 5.5 v*, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz test item symbol min max min max min max unit conditions address delay time t ad 20 30 40 ns figure 25.9 to address setup time t as 0.5 t cyc C 15 0.5 t cyc C 20 0.5 t cyc C 30 ns figure 25.13 address hold time t ah 0.5 t cyc C 10 0.5 t cyc C 15 0.5 t cyc C 20 ns &6 delay time ( ,26 ) t csd 20 30 40 ns $6 delay time t asd 30 45 60 ns 5' delay time 1 t rsd1 30 45 60 ns 5' delay time 2 t rsd2 30 45 60 ns read data setup time t rds 15 20 35 ns read data hold time t rdh 0 0 0 ns
723 table 25.7 bus timing (cont) C preliminary C condition a:v cc = 5.0 v 10%, v cc b = 5.0 v 10%, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b:v cc = 4.0 v to 5.5 v, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v*, v cc b = 2.7 v to 5.5 v*, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz test item symbol min max min max min max unit conditions read data access time 1 t acc1 1.0 t cyc C 30 1.0 t cyc C 40 1.0 t cyc C 60 ns figure 25.9 to figure 25.13 read data access time 2 t acc2 1.5 t cyc C 25 1.5 t cyc C 35 1.5 t cyc C 50 ns read data access time 3 t acc3 2.0 t cyc C 30 2.0 t cyc C 40 2.0 t cyc C 60 ns read data access time 4 t acc4 2.5 t cyc C 25 2.5 t cyc C 35 2.5 t cyc C 50 ns read data access time 5 t acc5 3.0 t cyc C 30 3.0 t cyc C 40 3.0 t cyc C 60 ns :5 delay time 1 t wrd1 30 45 60 ns :5 delay time 2 t wrd2 30 45 60 ns :5 pulse width 1 t wsw1 1.0 t cyc C 20 1.0 t cyc C 30 1.0 t cyc C 40 ns :5 pulse width 2 t wsw2 1.5 t cyc C 20 1.5 t cyc C 30 1.5 t cyc C 40 ns
724 table 25.7 bus timing (cont) C preliminary C condition a:v cc = 5.0 v 10%, v cc b = 5.0 v 10%, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b:v cc = 4.0 v to 5.5v, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v*, v cc b = 2.7 v to 5.5 v*, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz test item symbol min max min max min max unit conditions write data delay time t wdd 30 45 60 ns figure 25.9 to write data setup time t wds 0 0 0 ns figure 25.13 write data hold time t wdh 10 15 20 ns :$,7 setup time t wts 30 45 60 ns :$,7 hold time t wth 5 5 10 ns note: * for the low-voltage f-ztat version, v cc = 3.0 v to 5.5 v.
725 t rsd2 t 1 t ad t csd as * a23 to a0, ios * note: * as and ios are the same pin. the function is selected by the iose bit in syscr. t asd rd (read) t 2 t as t asd t acc2 t rsd1 t acc3 t rds t wrd2 t wrd2 t wdd t wsw1 t wdh d15 to d0 (read) hwr , lwr (write) d15 to d0 (write) t ah t ah t as t as t rdh figure 25.9 basic bus timing (two-state access)
726 t rsd2 t 2 as * a23 to a0, ios * t asd rd (read) t 3 t as t asd t acc4 t rsd1 t acc5 t rds t wrd1 t wrd2 t wds t wsw2 t wdh d15 to d0 (read) hwr , lwr (write) d15 to d0 (write) t 1 t wdd t ad t csd note: * as and ios are the same pin. the function is selected by the iose bit in syscr. t ah t ah t as t rdh figure 25.10 basic bus timing (three-state access)
727 t w as * a23 to a0, ios * rd (read) t 3 d15 to d0 (read) hwr , lwr (write) d15 to d0 (write) t 2 t wts t 1 t wth t wts t wth wait note: * as and ios are the same pin. the function is selected by the iose bit in syscr. figure 25.11 basic bus timing (three-state access with one wait state)
728 t rsd2 t 1 as * a23 to a0, ios * t 2 t ah t acc3 t rds d15 to d0 (read) t 2 or t 3 t as t 1 t asd t asd t rdh t ad rd (read) note: * as and ios are the same pin. the function is selected by the iose bit in syscr. figure 25.12 burst rom access timing (two-state access)
729 t rsd2 t 1 as * a23 to a0, ios * t 1 t acc1 d15 to d0 (read) t 2 or t 3 t rdh t ad rd (read) t rds note: * as and ios are the same pin. the function is selected by the iose bit in syscr. figure 25.13 burst rom access timing (one-state access)
730 25.3.4 timing of on-chip supporting modules tables 25.8 to 25.10 show the on-chip supporting module timing. the only on-chip supporting modules that can operate in subclock operation (? = 32.768 khz) are the i/o ports, external interrupts (nmi and irq0, 1, 2, 6, and 7), the watchdog timer, and the 8-bit timer (channels 0 and 1). table 25.8 timing of on-chip supporting modules (1) C preliminary C condition a:v cc = 5.0 v 10%, v cc b = 5.0 v 10%, v ss = 0 v, ? = 32.768 khz * 1 , 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b:v cc = 4.0 v to 5.5 v, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ? = 32.768 khz * 1 , 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v* 2 , v cc b = 2.7 v to 5.5 v, v ss = 0 v, ? = 32.768 khz * 1 , 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz test item symbol min max min max min max unit conditions i/o ports output data delay time t pwd 50 50 100 ns figure 25.14 input data setup time t prs 30 30 50 input data hold time t prh 30 30 50 frt timer output delay time t ftod 50 50 100 ns figure 25.15 timer input setup time t ftis 30 30 50 timer clock input setup time t ftcs 30 30 50 figure 25.16 timer clock single edge t ftcwh 1.5 1.5 1.5 t cyc pulse width both edges t ftcwl 2.5 2.5 2.5
731 table 25.8 timing of on-chip supporting modules (1) (cont) C preliminary C condition a:v cc = 5.0 v 10%, v cc b = 5.0 v 10%, v ss = 0 v, ? = 32.768 khz * 1 , 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b:v cc = 4.0 v to 5.5 v, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ? = 32.768 khz * 1 , 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v* 2 , v cc b = 2.7 v to 5.5 v, v ss = 0 v, ? = 32.768 khz * 1 , 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz test item symbol min max min max min max unit conditions tmr timer output delay time t tmod 50 50 100 ns figure 25.17 timer reset input setup time t tmrs 30 30 50 figure 25.19 timer clock input setup time t tmcs 30 30 50 figure 25.18 timer clock single edge t tmcwh 1.5 1.5 1.5 t cyc pulse width both edges t tmcwl 2.5 2.5 2.5 pwm, pwmx pulse output delay time t pwod 50 50 100 ns figure 25.20 sci input clock asynchro- nous t scyc 4 4 4 t cyc figure 25.21 cycle synchro- nous 6 6 6 input clock pulse width t sckw 0.4 0.6 0.4 0.6 0.4 0.6 t scyc input clock rise time t sckr 1.5 1.5 1.5 t cyc input clock fall time t sckf 1.5 1.5 1.5
732 table 25.8 timing of on-chip supporting modules (1) (cont) C preliminary C condition a:v cc = 5.0 v 10%, v cc b = 5.0 v 10%, v ss = 0 v, ? = 32.768 khz * 1 , 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b:v cc = 4.0 v to 5.5 v, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ? = 32.768 khz * 1 , 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v* 2 , v cc b = 2.7 v to 5.5 v, v ss = 0 v, ? = 32.768 khz * 1 , 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz test item symbol min max min max min max unit conditions sci transmit data delay time (synchronous) t txd 50 50 100 ns figure 25.22 receive data setup time (synchronous) t rxs 50 50 100 ns receive data hold time (synchronous) t rxh 50 50 100 ns a/d converter trigger input setup time t trgs 30 30 50 ns figure 25.23 wdt 5(62 output delay time t resd 100 120 200 ns figure 25.24 5(62 output pulse width t resow 132 132 132 t cyc notes: 1. only supporting modules that can be used in subclock operation 2. for the low-voltage f-ztat version, v cc = 3.0 v to 5.5 v.
733 ports 1 to 9, a, b (read) t 2 t 1 t pwd t prh t prs ports 1 to 6, 8, 9, a, b (write) figure 25.14 i/o port input/output timing t ftis t ftod ftoa, ftob ftia, ftib, ftic, ftid figure 25.15 frt input/output timing t ftcs ftci t ftcwh t ftcwl figure 25.16 frt clock input timing
734 tmo0, tmo1 tmox t tmod figure 25.17 8-bit timer output timing tmci0, tmci1 tmix, tmiy t tmcs t tmcs t tmcwh t tmcwl figure 25.18 8-bit timer clock input timing tmri0, tmri1 tmix, tmiy t tmrs figure 25.19 8-bit timer reset input timing pw15 to pw0, pwx1 to pwx0 t pwod figure 25.20 pwm, pwmx output timing
735 sck0 to sck2 t sckw t sckr t sckf t scyc figure 25.21 sck clock input timing txd0 to txd2 (transmit data) rxd0 to rxd2 (receive data) sck0 to sck2 t rxs t rxh t txd figure 25.22 sci input/output timing (synchronous mode) adtrg t trgs figure 25.23 a/d converter external trigger input timing t resow t resd t resd reso figure 25.24 wdt output timing ( 5(62 5(62 )
736 table 25.8 timing of on-chip supporting modules (2) C preliminary C condition a:v cc = 5.0 v 10%, v cc b = 5.0 v 10%, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b:v cc = 4.0 v to 5.5 v, v cc b = 4.0 v to 5.5 v, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v*, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz test item symbol min max min max min max unit conditions hif read cycle &6 /ha0 setup time t har 10 10 10 ns figure 25.25 &6 /ha0 hold time t hra 10 10 10 ns ,25 pulse width t hrpw 120 120 220 ns hdb delay time t hrd 100 100 200 ns hdb hold time t hrf 025 025 040 ns hirq delay time t hirq 120 120 200 ns hif write cycle &6 /ha0 setup time t haw 10 10 10 ns &6 /ha0 hold time t hwa 10 10 10 ns ,2: pulse width t hwpw 60 60 100 ns hdb setup time fast a20 gate not used t hdw 30 30 50 ns fast a20 gate used 45 55 85 ns hdb hold time t hwd 15 15 25 ns ga20 delay time t hga 90 90 180 ns note: * for the low-voltage f-ztat version, v cc = 3.0 v to 5.5 v.
737 cs /ha0 ior hdb7 to hdb0 valid data hirqi * (i = 1, 3, 4, 11, 12) t har t hrpw t hra t hrf t hirq t hrd cs /ha0 iow hdb7 to hdb0 ga20 t haw t hwpw t hwa t hwd t hga t hdw host interface read timing note: * the rising edge timing is the same as the port 4 and port b output timing. see figure 25.14. host interface write timing figure 25.25 host interface timing
738 table 25.9 keyboard buffer controller timing C preliminary C conditions:v cc = 2.7 v to 5.5 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c ratings test item symbol min typ max unit conditions notes kclk, kd output fall time t kbf 20 + 0.1cb 250 ns figure 25.26 kclk, kd input data hold time t kbih 150 ns kclk, kd input data setup time t kbis 150 ns kclk, kd output delay time t kbod 450 ns kclk, kd capacitive load cb 400 pf
739 1. reception kclk/ kd * kclk/ kd * t kbis t kbih transmission (b) t kbf 2. transmission (a) kclk/ kd * t1 t2 t kbod note: ?shown here is the clock scaled by 1/n when the operating mode is active medium-speed mode. * kclk: ps2ac to ps2cc kd: ps2ad to ps2cd figure 25.26 keyboard buffer controller timing
740 table 25.10 i 2 c bus timing C preliminary C conditions:v cc = 2.7 v to 5.5 v, v ss = 0 v, ? = 5 mhz to maximum operating frequency, t a = C20 to +75c ratings item symbol min typ max unit test conditions notes scl clock cycle time t scl 12 t cyc figure 25.27 scl clock high pulse width t sclh 3 t cyc scl clock low pulse width t scll 5 t cyc scl, sda input rise time t sr 7.5 * t cyc scl, sda input fall time t sf 300 ns scl, sda input spike pulse elimination time t sp 1t cyc sda input bus free time t buf 5 t cyc start condition input hold time t stah 3 t cyc retransmission start condition input setup time t stas 3 t cyc stop condition input setup time t stos 3 t cyc data input setup time t sdas 0.5 t cyc data input hold time t sdah 0 ns scl, sda capacitive load c b 400 pf note: * 17.5t cyc can be set according to the clock selected for use by the i 2 c module. for details, see section 16.4, usage notes.
741 sda0, sda1 v il v ih t buf p * p * s * t stah t sclh t sr t scll t scl t sf t sdah sr * t sdas t stas t sp t stos note: * s, p, and sr indicate the following conditions. s: p: sr: start condition stop condition retransmission start condition scl0, scl1 figure 25.27 i 2 c bus interface input/output timing (option)
742 25.4 a/d conversion characteristics tables 25.11 and 25.12 list the a/d conversion characteristics. table 25.11 a/d conversion characteristics (an7 to an0 input: 134/266-state conversion) C preliminary C condition a: v cc = 5.0 v 10%, av cc = 5.0 v 10%, av ref = 4.5 v to av cc v ss = av ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b: v cc = 4.0 v to 5.5 v, av cc = 4.0 v to 5.5 v, av ref = 4.0 v to av cc v ss = av ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v* 5 , av cc = 2.7 v to 5.5 v* 5 , av ref = 2.7 v to av cc * 5 v ss = av ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz item min typ max min typ max min typ max unit resolution 10 10 10 10 10 10 10 10 10 bits conversion time 6.7 8.4 13.4 s analog input capacitance 20 20 20 pf permissible signal- source 10 * 3 10 * 3 10 * 1 k w impedance 5 * 4 5 * 4 5 * 2 nonlinearity error 3.0 3.0 7.0 lsb offset error 3.5 3.5 7.5 lsb full-scale error 3.5 3.5 7.5 lsb quantization error 0.5 0.5 0.5 lsb absolute accuracy 4.0 4.0 8.0 lsb notes: 1. when 4.0 v av cc 5.5 v 2. when 2.7 v av cc < 4.0 v 3. when conversion time 3 11. 17 s (cks = 1 and ? 12 mhz, or cks = 0) 4. when conversion time < 11. 17 s (cks = 1 and ? > 12 mhz) 5. for the low-voltage f-ztat version, v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, and av ref = 3.0 v to av cc .
743 table 25.12 a/d conversion characteristics (cin15 to cin0 input: 134/266-state conversion) C preliminary C condition a: v cc = 5.0 v 10%, av cc = 5.0 v 10%, av ref = 4.5 v to av cc v ss = av ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b: v cc = 4.0 v to 5.5 v, av cc = 4.0 v to 5.5 v, av ref = 4.0 v to av cc v ss = av ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v* 5 , av cc = 2.7 v to 5.5 v* 5 , av ref = 2.7 v to av cc * 5 v ss = av ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz item min typ max min typ max min typ max unit resolution 10 10 10 10 10 10 10 10 10 bits conversion time 6.7 8.4 13.4 s analog input capacitance 20 20 20 pf permissible signal- source 10 * 3 10 * 3 10 * 1 k w impedance 5 * 4 5 * 4 5 * 2 nonlinearity error 5.0 5.0 11.0 lsb offset error 5.5 5.5 11.5 lsb full-scale error 5.5 5.5 11.5 lsb quantization error 0.5 0.5 0.5 lsb absolute accuracy 6.0 6.0 12.0 lsb notes: 1. when 4.0 v av cc 5.5 v 2. when 2.7 v av cc < 4.0 v 3. when conversion time 3 11. 17 s (cks = 1 and ? 12 mhz, or cks = 0) 4. when conversion time < 11. 17 s (cks = 1 and ? > 12 mhz) 5. for the low-voltage f-ztat version, v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, and av ref = 3.0 v to av cc .
744 25.5 d/a conversion characteristics table 25.13 lists the d/a conversion characteristics. table 25.13 d/a conversion characteristics C preliminary C condition a: v cc = 5.0 v 10%, av cc = 5.0 v 10%, av ref = 4.5 v to av cc v ss = av ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition b: v cc = 4.0 v to 5.5 v, av cc = 4.0 v to 5.5 v, av ref = 4.0 v to av cc v ss = av ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c (regular specifications), t a = C40 to +85c (wide-range specifications) condition c:v cc = 2.7 v to 5.5 v*, av cc = 2.7 v to 5.5 v*, av ref = 2.7 v to av cc *v ss = av ss = 0 v, ? = 2 mhz to maximum operating frequency, t a = C20 to +75c condition a condition b condition c 20 mhz 16 mhz 10 mhz item min typ max min typ max min typ max unit resolution 8 8 8 8 8 8 8 8 8 bits conversion time with 20 pf load capacitance 10 10 10 s absolute accuracy with 2 m w load resistance 1.0 1.5 1.0 1.5 2.0 3.0 lsb with 4 m w load resistance 1.0 1.0 2.0 note: * for the low-voltage f-ztat version, v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, and av ref = 3.0 v to av cc .
745 25.6 flash memory characteristics table 25.14 shows the flash memory characteristics. table 25.14 flash memory characteristics preliminary conditions (5 v version):v cc = 5.0 v 10%, v ss = 0 v, t a = 0 to +75c (regular specifications), t a = 0 to +85c (wide-range specifications) (low-voltage version): v cc = 3.0 v to 3.6v, v ss = 0 v, t a = 0 to 75c (programming/erasing operating temperature) item symbol min typ max unit test condition programming time * 1, * 2, * 4 tp 10 200 ms/ 32 bytes erase time * 1, * 3, * 5 te 100 1200 ms/ block reprogramming count n wec 100 times programming wait time after swe-bit setting * 1 x10s wait time after psu-bit setting * 1 y50s wait time after p-bit setting * 1, * 4 z 150 200 s wait time after p-bit clear * 1 a 10 s wait time after psu-bit clear * 1 b 10 s wait time after pv-bit setting * 1 g 4s wait time after dummy write * 1 e 2s wait time after pv-bit clear * 1 h 4s maximum programming count * 1, * 4, * 5 n 1000 times tp = 200 s
746 table 25.14 flash memory characteristics (cont) preliminary conditions (5 v version):v cc = 5.0 v 10%, v ss = 0 v, t a = 0 to +75c (regular specifications), t a = 0 to +85c (wide-range specifications) (low-voltage version): v cc = 3.0 v to 3.6v, v ss = 0 v, t a = 0 to 75c (programming/erasing operating temperature) item symbol min typ max unit test condition erase wait time after swe-bit setting * 1 x10s wait time after esu-bit setting * 1 y 200 s wait time after e-bit setting * 1, * 6 z510ms wait time after e-bit clear * 1 a 10 s wait time after esu-bit clear * 1 b 10 s wait time after ev-bit setting * 1 g 20 s wait time after dummy write * 1 e 2s wait time after ev-bit clear * 1 h 5s maximum erase count * 1, * 6, * 7 n 120 times te = 10 ms notes: 1. set the times according to the program/erase algorithms. 2. programming time per 32 bytes (shows the total period for which the p-bit in flmcr1 is set. it does not include the programming verification time.) 3. block erase time (shows the total period for which the e-bit in flmcr1 is set. it does not include the erase verification time.) 4. maximum programming time (tp (max) = wait time after p-bit setting (z) maximum programming count (n)) 5. number of times when the wait time after p-bit setting (z) = 200 s. the number of writes should be set according to the actual set value of z to allow programming within the maximum programming time (tp). 6. maximum erase time (te (max) = wait time after e-bit setting (z) maximum erase count (n)) 7. number of times when the wait time after e-bit setting (z) = 10 ms. the number of erases should be set according to the actual set value of z to allow erasing within the maximum erase time (te).
747 25.7 usage note the f-ztat and mask rom versions have been confirmed as fully meeting the reference values for electrical characteristics shown in this manual. however, actual performance figures, operating margins, noise margins, and other properties may vary due to differences in the manufacturing process, on-chip rom, layout patterns, etc. when system evaluation testing is carried out using the f-ztat version, the same evaluation tests should also be conducted for the mask rom version when changing over to that version.
748
749 appendix a instruction set a.1 instruction operation notation rd general register (destination ) * 1 rs general register (source) * 1 rn general register * 1 ern general register (32-bit register) mac multiply-and-accumulate register (32-bit register) * 2 (ead) destination operand (eas) source operand exr extend register ccr condition code register n n (negative) flag in ccr z z (zero) flag in ccr v v (overflow) flag in ccr c c (carry) flag in ccr pc program counter sp stack pointer #imm immediate data disp displacement + addition C subtraction multiplication division logical and logical or ? exclusive logical or ? transfer from left-hand operand to right-hand operand, or transition from left- hand state to right-hand state ? not (logical complement) ( ) < > operand contents :8/:16/:24/:32 8-, 16-, 24-, or 32-bit length notes: 1. general registers include 8-bit registers (r0h to r7h, r0l to r7l), 16-bit registers (r0 to r7, e0 to e7), and 32-bit registers (er0 to er7). 2. mac instructions cannot be used in the h8s/2148 series and h8s/2144 series.
750 condition code notation symbol meaning changes according operation result. * indeterminate (value not guaranteed). 0 always cleared to 0. 1 always set to 1. not affected by operation result.
751 table a.1 instruction set 1. data transfer instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc mov mov.b #xx:8,rd mov.b rs,rd mov.b @ers,rd mov.b @(d:16,ers),rd mov.b @(d:32,ers),rd mov.b @ers+,rd mov.b @aa:8,rd mov.b @aa:16,rd mov.b @aa:32,rd mov.b rs,@erd mov.b rs,@(d:16,erd) mov.b rs,@(d:32,erd) mov.b rs,@-erd mov.b rs,@aa:8 mov.b rs,@aa:16 mov.b rs,@aa:32 mov.w #xx:16,rd mov.w rs,rd mov.w @ers,rd mov.w @(d:16,ers),rd mov.w @(d:32,ers),rd mov.w @ers+,rd mov.w @aa:16,rd mov.w @aa:32,rd mov.w rs,@erd mov.w rs,@(d:16,erd) mov.w rs,@(d:32,erd) mov.w rs,@-erd mov.w rs,@aa:16 mov.w rs,@aa:32 #xx:8 ? rd8 rs8 ? rd8 @ers ? rd8 @(d:16,ers) ? rd8 @(d:32,ers) ? rd8 @ers ? rd8,ers32+1 ? ers32 @aa:8 ? rd8 @aa:16 ? rd8 @aa:32 ? rd8 rs8 ? @erd rs8 ? @(d:16,erd) rs8 ? @(d:32,erd) erd32-1 ? erd32,rs8 ? @erd rs8 ? @aa:8 rs8 ? @aa:16 rs8 ? @aa:32 #xx:16 ? rd16 rs16 ? rd16 @ers ? rd16 @(d:16,ers) ? rd16 @(d:32,ers) ? rd16 @ers ? rd16,ers32+2 ? ers32 @aa:16 ? rd16 @aa:32 ? rd16 rs16 ? @erd rs16 ? @(d:16,erd) rs16 ? @(d:32,erd) erd32-2 ? erd32,rs16 ? @erd rs16 ? @aa:16 rs16 ? @aa:32 b b b b b b b b b b b b b b b b w w w w w w w w w w w w w w 2 4 2 2 2 2 2 2 4 8 4 8 4 8 4 8 2 2 2 2 2 4 6 2 4 6 4 6 4 6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 2 3 5 3 2 3 4 2 3 5 3 2 3 4 2 1 2 3 5 3 3 4 2 3 5 3 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size
752 table a.1 instruction set (cont) 1. data transfer instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc mov pop push ldm stm movfpe movtpe mov.l #xx:32,erd mov.l ers,erd mov.l @ers,erd mov.l @(d:16,ers),erd mov.l @(d:32,ers),erd mov.l @ers+,erd mov.l @aa:16,erd mov.l @aa:32,erd mov.l ers,@erd mov.l ers,@(d:16,erd) mov.l ers,@(d:32,erd) mov.l ers,@-erd mov.l ers,@aa:16 mov.l ers,@aa:32 pop.w rn pop.l ern push.w rn push.l ern ldm @sp+,(erm-ern) stm (erm-ern),@-sp movfpe @aa:16,rd movtpe rs,@aa:16 #xx:32 ? erd32 ers32 ? erd32 @ers ? erd32 @(d:16,ers) ? erd32 @(d:32,ers) ? erd32 @ers ? erd32,ers32+4 ? ers32 @aa:16 ? erd32 @aa:32 ? erd32 ers32 ? @erd ers32 ? @(d:16,erd) ers32 ? @(d:32,erd) erd32-4 ? erd32,ers32 ? @erd ers32 ? @aa:16 ers32 ? @aa:32 @sp ? rn16,sp+2 ? sp @sp ? ern32,sp+4 ? sp sp-2 ? sp,rn16 ? @sp sp-4 ? sp,ern32 ? @sp (@sp ? ern32,sp+4 ? sp) repeated for each restored register. (sp-4 ? sp,ern32 ? @sp) repeated for each saved register. l l l l l l l l l l l l l l w l w l l l 6 2 4 4 6 10 6 10 4 4 6 8 6 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3 1 4 5 7 5 5 6 4 5 7 5 5 6 3 5 3 5 7/9/11 [1] 7/9/11 [1] [2] [2] 2 4 2 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size cannot be used with the h8s/2148 series and h8s/2144 series. ? ?
753 table a.1 instruction set (cont) 2. arithmetic instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc add addx adds inc daa sub subx subs dec add.b #xx:8,rd add.b rs,rd add.w #xx:16,rd add.w rs,rd add.l #xx:32,erd add.l ers,erd addx #xx:8,rd addx rs,rd adds #1,erd adds #2,erd adds #4,erd inc.b rd inc.w #1,rd inc.w #2,rd inc.l #1,erd inc.l #2,erd daa rd sub.b rs,rd sub.w #xx:16,rd sub.w rs,rd sub.l #xx:32,erd sub.l ers,erd subx #xx:8,rd subx rs,rd subs #1,erd subs #2,erd subs #4,erd dec.b rd dec.w #1,rd dec.w #2,rd dec.l #1,erd dec.l #2,erd rd8+#xx:8 ? rd8 rd8+rs8 ? rd8 rd16+#xx:16 ? rd16 rd16+rs16 ? rd16 erd32+#xx:32 ? erd32 erd32+ers32 ? erd32 rd8+#xx:8+c ? rd8 rd8+rs8+c ? rd8 erd32+1 ? erd32 erd32+2 ? erd32 erd32+4 ? erd32 rd8+1 ? rd8 rd16+1 ? rd16 rd16+2 ? rd16 erd32+1 ? erd32 erd32+2 ? erd32 rd8 decimal adjust ? rd8 rd8-rs8 ? rd8 rd16-#xx:16 ? rd16 rd16-rs16 ? rd16 erd32-#xx:32 ? erd32 erd32-ers32 ? erd32 rd8-#xx:8-c ? rd8 rd8-rs8-c ? rd8 erd32-1 ? erd32 erd32-2 ? erd32 erd32-4 ? erd32 rd8-1 ? rd8 rd16-1 ? rd16 rd16-2 ? rd16 erd32-1 ? erd32 erd32-2 ? erd32 b b w w l l b b l l l b w w l l b b w w l l b b l l l b w w l l 2 4 6 2 4 6 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 2 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 3 1 1 1 1 1 1 1 1 1 1 1 ? ? ? * ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [3] [3] [4] [4] ? ? ? ? ? ? ? ? * [3] [3] [4] [4] ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced ? ? ? ? ? [5] [5] ? ? ? [5] [5] ? ? size
754 table a.1 instruction set (cont) 2. arithmetic instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc das mulxu mulxs divxu divxs cmp neg extu exts tas das rd mulxu.b rs,rd mulxu.w rs,erd mulxs.b rs,rd mulxs.w rs,erd divxu.b rs,rd divxu.w rs,erd divxs.b rs,rd divxs.w rs,erd cmp.b #xx:8,rd cmp.b rs,rd cmp.w #xx:16,rd cmp.w rs,rd cmp.l #xx:32,erd cmp.l ers,erd neg.b rd neg.w rd neg.l erd extu.w rd extu.l erd exts.w rd exts.l erd tas @erd rd8 decimal adjust ? rd8 rd8 rs8 ? rd16 (unsigned multiplication) rd16 rs16 ? erd32 (unsigned multiplication) rd8 rs8 ? rd16 (signed multiplication) rd16 rs16 ? erd32 (signed multiplication) rd16 rs8 ? rd16 (rdh: remainder, rdl: quotient) (unsigned division) erd32 rs16 ? erd32 (ed: remainder, rd: quotient) (unsigned division) rd16 rs8 ? rd16 (rdh: remainder, rdl: quotient) (signed division) erd32 rs16 ? erd32 (ed: remainder, rd: quotient) (signed division) rd8-#xx:8 rd8-rs8 rd16-#xx:16 rd16-rs16 erd32-#xx:32 erd32-ers32 0-rd8 ? rd8 0-rd16 ? rd16 0-erd32 ? erd32 0 ? ( of rd16) 0 ? ( of erd32) ( of rd16) ? ( of rd16) ( of erd32) ? ( of erd32) erd-0 ? ccr set, (1) ? ( of @erd) b b w b w b w b w b b w w l l b w l w l w l b 2 2 2 4 4 2 2 4 4 2 2 2 2 2 2 2 2 2 2 1 12 20 13 21 12 20 13 21 1 1 2 1 3 1 1 1 1 1 1 1 1 4 operation condition code no. of states * 1 normal advanced * size * 4 2 4 6 [7] [6] [7] [6] [7] [8] [7] [8] [3] [3] [4] [4] 0 0 0 0 0 0 0
755 table a.1 instruction set (cont) 2. arithmetic instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc mac clrmac ldmac stmac mac @ern+,@erm+ clrmac ldmac ers,mach ldmac ers,macl stmac mach,erd stmac macl,erd cannot be used with the h8s/2148 series and h8s/2144 series. [2] operation condition code no. of states * 1 normal advanced size
756 table a.1 instruction set (cont) 3. logic instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc and or xor not and.b #xx:8,rd and.b rs,rd and.w #xx:16,rd and.w rs,rd and.l #xx:32,erd and.l ers,erd or.b #xx:8,rd or.b rs,rd or.w #xx:16,rd or.w rs,rd or.l #xx:32,erd or.l ers,erd xor.b #xx:8,rd xor.b rs,rd xor.w #xx:16,rd xor.w rs,rd xor.l #xx:32,erd xor.l ers,erd not.b rd not.w rd not.l erd rd8 #xx:8 ? rd8 rd8 rs8 ? rd8 rd16 #xx:16 ? rd16 rd16 rs16 ? rd16 erd32 #xx:32 ? erd32 erd32 ers32 ? erd32 rd8 #xx:8 ? rd8 rd8 rs8 ? rd8 rd16 #xx:16 ? rd16 rd16 rs16 ? rd16 erd32 #xx:32 ? erd32 erd32 ers32 ? erd32 rd8 ? #xx:8 ? rd8 rd8 ? rs8 ? rd8 rd16 ? #xx:16 ? rd16 rd16 ? rs16 ? rd16 erd32 ? #xx:32 ? erd32 erd32 ? ers32 ? erd32 ?rd8 ? rd8 ?rd16 ? rd16 ?erd32 ? erd32 b b w w l l b b w w l l b b w w l l b w l 2 4 6 2 4 6 2 4 6 2 2 4 2 2 4 2 2 4 2 2 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 2 1 3 2 1 1 2 1 3 2 1 1 2 1 3 2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size
757 table a.1 instruction set (cont) 4. shift instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc shal shar shll shlr rotxl shal.b rd shal.b #2,rd shal.w rd shal.w #2,rd shal.l erd shal.l #2,erd shar.b rd shar.b #2,rd shar.w rd shar.w #2,rd shar.l erd shar.l #2,erd shll.b rd shll.b #2,rd shll.w rd shll.w #2,rd shll.l erd shll.l #2,erd shlr.b rd shlr.b #2,rd shlr.w rd shlr.w #2,rd shlr.l erd shlr.l #2,erd rotxl.b rd rotxl.b #2,rd rotxl.w rd rotxl.w #2,rd rotxl.l erd rotxl.l #2,erd b b w w l l b b w w l l b b w w l l b b w w l l b b w w l l 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size c msb lsb 0 c 0 msb lsb 0 c msb lsb c msb lsb c msb lsb
758 table a.1 instruction set (cont) 4. shift instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc rotxr rotl rotr rotxr.b rd rotxr.b #2,rd rotxr.w rd rotxr.w #2,rd rotxr.l erd rotxr.l #2,erd rotl.b rd rotl.b #2,rd rotl.w rd rotl.w #2,rd rotl.l erd rotl.l #2,erd rotr.b rd rotr.b #2,rd rotr.w rd rotr.w #2,rd rotr.l erd rotr.l #2,erd b b w w l l b b w w l l b b w w l l 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size c msb lsb c msb lsb c msb lsb
759 table a.1 instruction set (cont) 5. bit manipulation instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc bset bclr bnot bset #xx:3,rd bset #xx:3,@erd bset #xx:3,@aa:8 bset #xx:3,@aa:16 bset #xx:3,@aa:32 bset rn,rd bset rn,@erd bset rn,@aa:8 bset rn,@aa:16 bset rn,@aa:32 bclr #xx:3,rd bclr #xx:3,@erd bclr #xx:3,@aa:8 bclr #xx:3,@aa:16 bclr #xx:3,@aa:32 bclr rn,rd bclr rn,@erd bclr rn,@aa:8 bclr rn,@aa:16 bclr rn,@aa:32 bnot #xx:3,rd bnot #xx:3,@erd bnot #xx:3,@aa:8 bnot #xx:3,@aa:16 bnot #xx:3,@aa:32 bnot rn,rd bnot rn,@erd bnot rn,@aa:8 bnot rn,@aa:16 bnot rn,@aa:32 (#xx:3 of rd8) ? 1 (#xx:3 of @erd) ? 1 (#xx:3 of @aa:8) ? 1 (#xx:3 of @aa:16) ? 1 (#xx:3 of @aa:32) ? 1 (rn8 of rd8) ? 1 (rn8 of @erd) ? 1 (rn8 of @aa:8) ? 1 (rn8 of @aa:16) ? 1 (rn8 of @aa:32) ? 1 (#xx:3 of rd8) ? 0 (#xx:3 of @erd) ? 0 (#xx:3 of @aa:8) ? 0 (#xx:3 of @aa:16) ? 0 (#xx:3 of @aa:32) ? 0 (rn8 of rd8) ? 0 (rn8 of @erd) ? 0 (rn8 of @aa:8) ? 0 (rn8 of @aa:16) ? 0 (rn8 of @aa:32) ? 0 (#xx:3 of rd8) ? [?(#xx:3 of rd8)] (#xx:3 of @erd) ? [?(#xx:3 of @erd)] (#xx:3 of @aa:8) ? [?(#xx:3 of @aa:8)] (#xx:3 of @aa:16) ? [?(#xx:3 of @aa:16)] (#xx:3 of @aa:32) ? [?(#xx:3 of @aa:32)] (rn8 of rd8) ? [?(rn8 of rd8)] (rn8 of @erd) ? [?(rn8 of @erd)] (rn8 of @aa:8) ? [?(rn8 of @aa:8)] (rn8 of @aa:16) ? [?(rn8 of @aa:16)] (rn8 of @aa:32) ? [?(rn8 of @aa:32)] b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 4 4 5 6 1 4 4 5 6 1 4 4 5 6 1 4 4 5 6 1 4 4 5 6 1 4 4 5 6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size
760 table a.1 instruction set (cont) 5. bit manipulation instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc btst bld bild bst bist btst #xx:3,rd btst #xx:3,@erd btst #xx:3,@aa:8 btst #xx:3,@aa:16 btst #xx:3,@aa:32 btst rn,rd btst rn,@erd btst rn,@aa:8 btst rn,@aa:16 btst rn,@aa:32 bld #xx:3,rd bld #xx:3,@erd bld #xx:3,@aa:8 bld #xx:3,@aa:16 bld #xx:3,@aa:32 bild #xx:3,rd bild #xx:3,@erd bild #xx:3,@aa:8 bild #xx:3,@aa:16 bild #xx:3,@aa:32 bst #xx:3,rd bst #xx:3,@erd bst #xx:3,@aa:8 bst #xx:3,@aa:16 bst #xx:3,@aa:32 bist #xx:3,rd bist #xx:3,@erd bist #xx:3,@aa:8 bist #xx:3,@aa:16 bist #xx:3,@aa:32 ?(#xx:3 of rd8) ? z ?(#xx:3 of @erd) ? z ?(#xx:3 of @aa:8) ? z ?(#xx:3 of @aa:16) ? z ?(#xx:3 of @aa:32) ? z ?(rn8 of rd8) ? z ?(rn8 of @erd) ? z ?(rn8 of @aa:8) ? z ?(rn8 of @aa:16) ? z ?(rn8 of @aa:32) ? z (#xx:3 of rd8) ? c (#xx:3 of @erd) ? c (#xx:3 of @aa:8) ? c (#xx:3 of @aa:16) ? c (#xx:3 of @aa:32) ? c ?(#xx:3 of rd8) ? c ?(#xx:3 of @erd) ? c ?(#xx:3 of @aa:8) ? c ?(#xx:3 of @aa:16) ? c ?(#xx:3 of @aa:32) ? c c ? (#xx:3 of rd8) c ? (#xx:3 of @erd) c ? (#xx:3 of @aa:8) c ? (#xx:3 of @aa:16) c ? (#xx:3 of @aa:32) ?c ? (#xx:3 of rd8) ?c ? (#xx:3 of @erd) ?c ? (#xx:3 of @aa:8) ?c ? (#xx:3 of @aa:16) ?c ? (#xx:3 of @aa:32) b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 4 4 5 6 1 4 4 5 6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size
761 table a.1 instruction set (cont) 5. bit manipulation instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc band biand bor bior bxor bixor band #xx:3,rd band #xx:3,@erd band #xx:3,@aa:8 band #xx:3,@aa:16 band #xx:3,@aa:32 biand #xx:3,rd biand #xx:3,@erd biand #xx:3,@aa:8 biand #xx:3,@aa:16 biand #xx:3,@aa:32 bor #xx:3,rd bor #xx:3,@erd bor #xx:3,@aa:8 bor #xx:3,@aa:16 bor #xx:3,@aa:32 bior #xx:3,rd bior #xx:3,@erd bior #xx:3,@aa:8 bior #xx:3,@aa:16 bior #xx:3,@aa:32 bxor #xx:3,rd bxor #xx:3,@erd bxor #xx:3,@aa:8 bxor #xx:3,@aa:16 bxor #xx:3,@aa:32 bixor #xx:3,rd bixor #xx:3,@erd bixor #xx:3,@aa:8 bixor #xx:3,@aa:16 bixor #xx:3,@aa:32 c (#xx:3 of rd8) ? c c (#xx:3 of @erd) ? c c (#xx:3 of @aa:8) ? c c (#xx:3 of @aa:16) ? c c (#xx:3 of @aa:32) ? c c [?(#xx:3 of rd8)] ? c c [?(#xx:3 of @erd)] ? c c [?(#xx:3 of @aa:8)] ? c c [?(#xx:3 of @aa:16)] ? c c [?(#xx:3 of @aa:32)] ? c c (#xx:3 of rd8) ? c c (#xx:3 of @erd) ? c c (#xx:3 of @aa:8) ? c c (#xx:3 of @aa:16) ? c c (#xx:3 of @aa:32) ? c c [?(#xx:3 of rd8)] ? c c [?(#xx:3 of @erd)] ? c c [?(#xx:3 of @aa:8)] ? c c [?(#xx:3 of @aa:16)] ? c c [?(#xx:3 of @aa:32)] ? c c ? (#xx:3 of rd8) ? c c ? (#xx:3 of @erd) ? c c ? (#xx:3 of @aa:8) ? c c ? (#xx:3 of @aa:16) ? c c ? (#xx:3 of @aa:32) ? c c ? [?(#xx:3 of rd8)] ? c c ? [?(#xx:3 of @erd)] ? c c ? [?(#xx:3 of @aa:8)] ? c c ? [?(#xx:3 of @aa:16)] ? c c ? [?(#xx:3 of @aa:32)] ? c b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size
762 table a.1 instruction set (cont) 6. branch instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc bcc bra d:8(bt d:8) bra d:16(bt d:16) brn d:8(bf d:8) brn d:16(bf d:16) bhi d:8 bhi d:16 bls d:8 bls d:16 bcc d:8(bhs d:8) bcc d:16(bhs d:16) bcs d:8(blo d:8) bcs d:16(blo d:16) bne d:8 bne d:16 beq d:8 beq d:16 bvc d:8 bvc d:16 bvs d:8 bvs d:16 bpl d:8 bpl d:16 bmi d:8 bmi d:16 bge d:8 bge d:16 blt d:8 blt d:16 bgt d:8 bgt d:16 ble d:8 ble d:16 if condition is true then pc ? pc+d else next; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size always never c z=0 c z=1 c=0 c=1 z=0 z=1 v=0 v=1 n=0 n=1 n ? v=0 n ? v=1 z (n ? v)=0 z (n ? v)=1 branch condition
763 table a.1 instruction set (cont) 6. branch instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc jmp bsr jsr rts jmp @ern jmp @aa:24 jmp @@aa:8 bsr d:8 bsr d:16 jsr @ern jsr @aa:24 jsr @@aa:8 rts pc ? ern pc ? aa:24 pc ? @aa:8 pc ? @-sp,pc ? pc+d:8 pc ? @-sp,pc ? pc+d:16 pc ? @-sp,pc ? ern pc ? @-sp,pc ? aa:24 pc ? @-sp,pc ? @aa:8 pc ? @sp+ ? ? ? ? ? ? ? ? 2 2 4 4 ? ? ? ? ? ? ? ? 2 3 2 4 2 2 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size 4 3 4 3 4 4 4 5 4 5 4 5 6 5
764 table a.1 instruction set (cont) 7. system control instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc trapa rte sleep ldc trapa #xx:2 rte sleep ldc #xx:8,ccr ldc #xx:8,exr ldc rs,ccr ldc rs,exr ldc @ers,ccr ldc @ers,exr ldc @(d:16,ers),ccr ldc @(d:16,ers),exr ldc @(d:32,ers),ccr ldc @(d:32,ers),exr ldc @ers+,ccr ldc @ers+,exr ldc @aa:16,ccr ldc @aa:16,exr ldc @aa:32,ccr ldc @aa:32,exr pc ? @-sp,ccr ? @-sp, exr ? @-sp, ? pc exr ? @sp+,ccr ? @sp+, pc ? @sp+ transition to power-down state #xx:8 ? ccr #xx:8 ? exr rs8 ? ccr rs8 ? exr @ers ? ccr @ers ? exr @(d:16,ers) ? ccr @(d:16,ers) ? exr @(d:32,ers) ? ccr @(d:32,ers) ? exr @ers ? ccr,ers32+2 ? ers32 @ers ? exr,ers32+2 ? ers32 @aa:16 ? ccr @aa:16 ? exr @aa:32 ? ccr @aa:32 ? exr ? ? ? b b b b w w w w w w w w w w w w 2 4 2 2 4 4 6 6 10 10 4 4 6 6 8 8 1 ? ? ? ? ? ? ? ? 7 [9] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size 5 [9] 2 1 2 1 1 3 3 4 4 6 6 4 4 4 4 5 5 8 [9]
765 table a.1 instruction set (cont) 7. system control instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc stc andc orc xorc nop stc ccr,rd stc exr,rd stc ccr,@erd stc exr,@erd stc ccr,@(d:16,erd) stc exr,@(d:16,erd) stc ccr,@(d:32,erd) stc exr,@(d:32,erd) stc ccr,@-erd stc exr,@-erd stc ccr,@aa:16 stc exr,@aa:16 stc ccr,@aa:32 stc exr,@aa:32 andc #xx:8,ccr andc #xx:8,exr orc #xx:8,ccr orc #xx:8,exr xorc #xx:8,ccr xorc #xx:8,exr nop ccr ? rd8 exr ? rd8 ccr ? @erd exr ? @erd ccr ? @(d:16,erd) exr ? @(d:16,erd) ccr ? @(d:32,erd) exr ? @(d:32,erd) erd32-2 ? erd32,ccr ? @erd erd32-2 ? erd32,exr ? @erd ccr ? @aa:16 exr ? @aa:16 ccr ? @aa:32 exr ? @aa:32 ccr #xx:8 ? ccr exr #xx:8 ? exr ccr #xx:8 ? ccr exr #xx:8 ? exr ccr ? #xx:8 ? ccr exr ? #xx:8 ? exr pc ? pc+2 b b w w w w w w w w w w w w b b b b b b 2 4 2 4 2 4 2 2 4 4 6 6 10 10 4 4 6 6 8 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 3 3 4 4 6 6 4 4 4 4 5 5 1 2 1 2 1 2 1 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size
766 table a.1 instruction set (cont) 8. block transfer instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc eepmov eepmov.b eepmov.w if r4l 1 0 repeat @er5 ? @er6 er5+1 ? er5 er6+1 ? er6 r4l-1 ? r4l until r4l=0 else next; if r4 1 0 repeat @er5 ? @er6 er5+1 ? er5 er6+1 ? er6 r4-1 ? r4 until r4=0 else next; ? 4+2n * 2 4+2n * 2 4 4 ? ? ? operation condition code no. of states * 1 normal advanced ? ? size notes: 1. the number of states is the number of states required for execution when the instruction and its operands are located in on-chip memory. 2. n is the initial value set in r4l or r4. [1] 7 states when the number of saved/restored registers is 2, 9 states when 3, and 11 states when 4. [2] cannot be used with the h8s/2148 series and h8s/2144 series. [3] set to 1 when there is a carry from or borrow to bit 11; otherwise cleared to 0. [4] set to 1 when there is a carry from or borrow to bit 27; otherwise cleared to 0. [5] if the result is zero, the previous value of the flag is retained; otherwise the flag is cleared to 0. [6] set to 1 if the divisor is negative; otherwise cleared to 0. [7] set to 1 if the divisor is zero; otherwise cleared to 0. [8] set to 1 if the quotient is negative; otherwise cleared to 0. [9] when exr is valid, the number of states is increased by 1.
767 a.2 instruction codes table a.2 instruction codes add.b #xx:8,rd add.b rs,rd add.w #xx:16,rd add.w rs,rd add.l #xx:32,erd add.l ers,erd adds #1,erd adds #2,erd adds #4,erd addx #xx:8,rd addx rs,rd and.b #xx:8,rd and.b rs,rd and.w #xx:16,rd and.w rs,rd and.l #xx:32,erd and.l ers,erd andc #xx:8,ccr andc #xx:8,exr band #xx:3,rd band #xx:3,@erd band #xx:3,@aa:8 band #xx:3,@aa:16 band #xx:3,@aa:32 bra d:8 (bt d:8) bra d:16 (bt d:16) brn d:8 (bf d:8) brn d:16 (bf d:16) mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion add adds addx and andc band bcc b b w w l l l l l b b b b w w l l b b b b b b b ? ? ? 1 0 0 ers imm erd 0 0 0 0 0 0 erd erd erd erd erd erd ers imm imm 0 erd 0 imm 0 imm 0 0 0 8 0 7 0 7 0 0 0 0 9 0 e 1 7 6 7 0 0 0 7 7 7 6 6 4 5 4 5 rd 8 9 9 a a b b b rd e rd 6 9 6 a 1 6 1 6 c e a a 0 8 1 8 rd rd rd rd rd rd rd 0 1 rd 0 0 0 0 0 6 0 7 7 6 6 6 6 0 0 76 0 76 0 imm imm imm imm abs disp disp rs 1 rs 1 0 8 9 rs rs 6 rs 6 f 4 1 3 0 1 imm imm abs disp disp imm imm abs imm
768 table a.2 instruction codes (cont) bhi d:8 bhi d:16 bls d:8 bls d:16 bcc d:8 (bhs d:8) bcc d:16 (bhs d:16) bcs d:8 (blo d:8) bcs d:16 (blo d:16) bne d:8 bne d:16 beq d:8 beq d:16 bvc d:8 bvc d:16 bvs d:8 bvs d:16 bpl d:8 bpl d:16 bmi d:8 bmi d:16 bge d:8 bge d:16 blt d:8 blt d:16 bgt d:8 bgt d:16 ble d:8 ble d:16 mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion bcc ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 2 8 3 8 4 8 5 8 6 8 7 8 8 8 9 8 a 8 b 8 c 8 d 8 e 8 f 8 2 3 4 5 6 7 8 9 a b c d e f disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp 0 0 0 0 0 0 0 0 0 0 0 0 0 0
769 table a.2 instruction codes (cont) bclr #xx:3,rd bclr #xx:3,@erd bclr #xx:3,@aa:8 bclr #xx:3,@aa:16 bclr #xx:3,@aa:32 bclr rn,rd bclr rn,@erd bclr rn,@aa:8 bclr rn,@aa:16 bclr rn,@aa:32 biand #xx:3,rd biand #xx:3,@erd biand #xx:3,@aa:8 biand #xx:3,@aa:16 biand #xx:3,@aa:32 bild #xx:3,rd bild #xx:3,@erd bild #xx:3,@aa:8 bild #xx:3,@aa:16 bild #xx:3,@aa:32 bior #xx:3,rd bior #xx:3,@erd bior #xx:3,@aa:8 bior #xx:3,@aa:16 bior #xx:3,@aa:32 mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion bclr biand bild bior b b b b b b b b b b b b b b b b b b b b b b b b b 0 0 0 1 0 1 0 1 0 imm erd erd imm erd imm erd imm erd 0 1 1 1 imm imm imm imm 0 1 1 1 imm imm imm imm 7 7 7 6 6 6 7 7 6 6 7 7 7 6 6 7 7 7 6 6 7 7 7 6 6 2 d f a a 2 d f a a 6 c e a a 7 c e a a 4 c e a a 1 3 rn 1 3 1 3 1 3 1 3 rd 0 8 8 rd 0 8 8 rd 0 0 0 rd 0 0 0 rd 0 0 0 7 7 6 6 7 7 7 7 7 7 2 2 2 2 6 6 7 7 4 4 rn rn 0 0 0 0 0 0 0 0 0 0 7 6 7 7 7 2 2 6 7 4 rn 0 0 0 0 0 7 6 7 7 7 2 2 6 7 4 rn 0 0 0 0 0 abs abs abs abs abs abs abs abs abs abs abs abs abs abs abs 0 0 1 1 1 1 1 1 imm imm imm imm imm imm imm imm
770 table a.2 instruction codes (cont) bist #xx:3,rd bist #xx:3,@erd bist #xx:3,@aa:8 bist #xx:3,@aa:16 bist #xx:3,@aa:32 bixor #xx:3,rd bixor #xx:3,@erd bixor #xx:3,@aa:8 bixor #xx:3,@aa:16 bixor #xx:3,@aa:32 bld #xx:3,rd bld #xx:3,@erd bld #xx:3,@aa:8 bld #xx:3,@aa:16 bld #xx:3,@aa:32 bnot #xx:3,rd bnot #xx:3,@erd bnot #xx:3,@aa:8 bnot #xx:3,@aa:16 bnot #xx:3,@aa:32 bnot rn,rd bnot rn,@erd bnot rn,@aa:8 bnot rn,@aa:16 bnot rn,@aa:32 mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion bist bixor bld bnot b b b b b b b b b b b b b b b b b b b b b b b b b 1 0 1 0 0 0 0 0 0 imm erd imm erd imm erd imm erd erd imm imm imm imm imm imm imm imm 1 1 0 0 imm imm imm imm 1 1 0 0 imm imm imm imm 1 1 1 1 0 0 0 0 6 7 7 6 6 7 7 7 6 6 7 7 7 6 6 7 7 7 6 6 6 7 7 6 6 7 d f a a 5 c e a a 7 c e a a 1 d f a a 1 d f a a 1 3 1 3 1 3 1 3 rn 1 3 rd 0 8 8 rd 0 0 0 rd 0 0 0 rd 0 8 8 rd 0 8 8 6 6 7 7 7 7 7 7 6 6 7 7 5 5 7 7 1 1 1 1 rn rn 0 0 0 0 0 0 0 0 0 0 6 7 7 7 6 7 5 7 1 1 rn 0 0 0 0 0 6 7 7 7 6 7 5 7 1 1 rn 0 0 0 0 0 abs abs abs abs abs abs abs abs abs abs abs abs abs abs abs
771 table a.2 instruction codes (cont) bor #xx:3,rd bor #xx:3,@erd bor #xx:3,@aa:8 bor #xx:3,@aa:16 bor #xx:3,@aa:32 bset #xx:3,rd bset #xx:3,@erd bset #xx:3,@aa:8 bset #xx:3,@aa:16 bset #xx:3,@aa:32 bset rn,rd bset rn,@erd bset rn,@aa:8 bset rn,@aa:16 bset rn,@aa:32 bsr d:8 bsr d:16 bst #xx:3,rd bst #xx:3,@erd bst #xx:3,@aa:8 bst #xx:3,@aa:16 bst #xx:3,@aa:32 btst #xx:3,rd btst #xx:3,@erd btst #xx:3,@aa:8 btst #xx:3,@aa:16 btst #xx:3,@aa:32 btst rn,rd btst rn,@erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion bor bset bsr bst btst b b b b b b b b b b b b b b b ? ? b b b b b b b b b b b b 0 0 0 0 0 0 0 0 0 0 imm erd imm erd erd imm erd imm erd erd abs abs abs disp abs abs imm imm imm imm imm imm imm imm 0 0 0 0 imm imm imm imm 0 0 0 0 imm imm imm imm 0 0 0 0 0 0 0 0 7 7 7 6 6 7 7 7 6 6 6 7 7 6 6 5 5 6 7 7 6 6 7 7 7 6 6 6 7 4 c e a a 0 d f a a 0 d f a a 5 c 7 d f a a 3 c e a a 3 c 1 3 1 3 rn 1 3 0 1 3 1 3 rn rd 0 0 0 rd 0 8 8 rd 0 8 8 0 rd 0 8 8 rd 0 0 0 rd 0 7 7 7 7 6 6 6 6 7 7 6 4 4 0 0 0 0 7 7 3 3 3 rn rn rn 0 0 0 0 0 0 0 0 0 0 0 7 7 6 6 7 4 0 0 7 3 rn 0 0 0 0 0 7 7 6 6 7 4 0 0 7 3 rn 0 0 0 0 0 abs abs abs disp abs abs abs abs abs abs abs
772 table a.2 instruction codes (cont) btst rn,@aa:8 btst rn,@aa:16 btst rn,@aa:32 bxor #xx:3,rd bxor #xx:3,@erd bxor #xx:3,@aa:8 bxor #xx:3,@aa:16 bxor #xx:3,@aa:32 clrmac cmp.b #xx:8,rd cmp.b rs,rd cmp.w #xx:16,rd cmp.w rs,rd cmp.l #xx:32,erd cmp.l ers,erd daa rd das rd dec.b rd dec.w #1,rd dec.w #2,rd dec.l #1,erd dec.l #2,erd divxs.b rs,rd divxs.w rs,erd divxu.b rs,rd divxu.w rs,erd eepmov.b eepmov.w mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion btst bxor clrmac cmp daa das dec divxs divxu eepmov b b b b b b b b ? b b w w l l b b b w w l l b w b w ? 0 0 1 imm erd ers 0 0 0 0 0 erd erd erd erd erd imm imm 0 erd 0 imm 0 imm 0 0 7 6 6 7 7 7 6 6 a 1 7 1 7 1 0 1 1 1 1 1 1 0 0 5 5 7 7 e a a 5 c e a a rd c 9 d a f f f a b b b b 1 1 1 3 b b 1 3 1 3 rs 2 rs 2 0 0 0 5 d 7 f d d rs rs 5 d 0 0 rd 0 0 0 rd rd rd rd rd rd rd rd 0 0 rd c 4 6 7 7 5 5 5 5 3 5 5 1 3 9 9 rn rs rs 8 8 0 0 0 rd f f 6 7 3 5 rn 0 0 6 7 3 5 rn 0 0 abs abs imm abs abs imm abs abs imm cannot be used with the h8s/2148 series and h8s/2144 series.
773 table a.2 instruction codes (cont) exts.w rd exts.l erd extu.w rd extu.l erd inc.b rd inc.w #1,rd inc.w #2,rd inc.l #1,erd inc.l #2,erd jmp @ern jmp @aa:24 jmp @@aa:8 jsr @ern jsr @aa:24 jsr @@aa:8 ldc #xx:8,ccr ldc #xx:8,exr ldc rs,ccr ldc rs,exr ldc @ers,ccr ldc @ers,exr ldc @(d:16,ers),ccr ldc @(d:16,ers),exr ldc @(d:32,ers),ccr ldc @(d:32,ers),exr ldc @ers+,ccr ldc @ers+,exr ldc @aa:16,ccr ldc @aa:16,exr mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion exts extu inc jmp jsr ldc w l w l b w w l l ? ? ? ? ? ? b b b b w w w w w w w w w w 0 0 ern ern 0 0 0 0 erd erd erd erd ers ers ers ers ers ers ers ers 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 5 5 5 5 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 a b b b b 9 a b d e f 7 1 3 3 1 1 1 1 1 1 1 1 1 1 d f 5 7 0 5 d 7 f 4 0 1 4 4 4 4 4 4 4 4 4 4 rd rd rd rd rd 0 0 1 rs rs 0 1 0 1 0 1 0 1 0 1 0 6 6 6 6 7 7 6 6 6 6 7 9 9 f f 8 8 d d b b 0 0 0 0 0 0 0 0 0 0 0 0 6 6 b b 2 2 0 0 abs abs abs abs imm imm disp disp disp disp disp disp
774 table a.2 instruction codes (cont) 0 0 rd abs rs rd ldc @aa:32,ccr ldc @aa:32,exr ldm.l @sp+, (ern-ern+1) ldm.l @sp+, (ern-ern+2) ldm.l @sp+, (ern-ern+3) ldmac ers,mach ldmac ers,macl mac @ern+,@erm+ mov.b #xx:8,rd mov.b rs,rd mov.b @ers,rd mov.b @(d:16,ers),rd mov.b @(d:32,ers),rd mov.b @ers+,rd mov.b @aa:8,rd mov.b @aa:16,rd mov.b @aa:32,rd mov.b rs,@erd mov.b rs,@(d:16,erd) mov.b rs,@(d:32,erd) mov.b rs,@-erd mov.b rs,@aa:8 mov.b rs,@aa:16 mov.b rs,@aa:32 mov.w #xx:16,rd mov.w rs,rd mov.w @ers,rd mov.w @(d:16,ers),rd mov.w @(d:32,ers),rd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion ldc ldm ldmac mac mov w w l l l l l ? b b b b b b b b b b b b b b b b w w w w w 0 0 0 0 1 1 0 1 0 0 0 ers ers ers ers erd erd erd erd ers ers ers 0 0 0 ern+1 ern+2 ern+3 0 0 0 0 0 f 0 6 6 7 6 2 6 6 6 6 7 6 3 6 6 7 0 6 6 7 1 1 1 1 1 rd c 8 e 8 c rd a a 8 e 8 c rs a a 9 d 9 f 8 4 4 1 2 3 rs 0 2 8 a 0 rs 0 1 0 0 0 rd rd rd 0 rd rd rd rs rs 0 rs rs rs rd rd rd rd 0 6 6 6 6 6 6 6 6 b b d d d a a b 2 2 7 7 7 2 a 2 imm abs abs disp abs disp abs imm disp abs abs abs abs disp disp disp cannot be used with the h8s/2148 series and h8s/2144 series.
775 table a.2 instruction codes (cont) mov.w @ers+,rd mov.w @aa:16,rd mov.w @aa:32,rd mov.w rs,@erd mov.w rs,@(d:16,erd) mov.w rs,@(d:32,erd) mov.w rs,@-erd mov.w rs,@aa:16 mov.w rs,@aa:32 mov.l #xx:32,rd mov.l ers,erd mov.l @ers,erd mov.l @(d:16,ers),erd mov.l @(d:32,ers),erd mov.l @ers+,erd mov.l @aa:16 ,erd mov.l @aa:32 ,erd mov.l ers,@erd mov.l ers,@(d:16,erd) mov.l ers,@(d:32,erd) * mov.l ers,@-erd mov.l ers,@aa:16 mov.l ers,@aa:32 movfpe @aa:16,rd movtpe rs,@aa:16 mulxs.b rs,rd mulxs.w rs,erd mulxu.b rs,rd mulxu.w rs,erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion mov movfpe movtpe mulxs mulxu w w w w w w w w w l l l l l l l l l l l l l l b b b w b w 0 1 1 0 1 1 ers erd erd erd erd ers 0 0 0 erd erd erd ers ers ers ers erd erd erd erd 0 0 0 0 0 0 0 0 0 0 0 erd erd erd erd erd ers ers ers ers ers erd 0 0 erd ers 0 0 0 0 1 1 0 1 6 6 6 6 6 7 6 6 6 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 d b b 9 f 8 d b b a f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 0 2 8 a 0 0 0 0 0 0 0 0 0 0 0 0 0 c c rs rs rd rd rd rs rs 0 rs rs rs 0 0 0 0 0 0 0 0 0 0 0 0 0 0 rd 6 6 6 7 6 6 6 6 6 7 6 6 6 5 5 b 9 f 8 d b b 9 f 8 d b b 0 2 a 0 2 8 a rs rs rs 0 0 rd 6 6 b b 2 a abs disp abs abs abs imm disp abs disp abs disp abs abs disp disp cannot be used with the h8s/2148 series and h8s/2144 series.
776 table a.2 instruction codes (cont) neg.b rd neg.w rd neg.l erd nop not.b rd not.w rd not.l erd or.b #xx:8,rd or.b rs,rd or.w #xx:16,rd or.w rs,rd or.l #xx:32,erd or.l ers,erd orc #xx:8,ccr orc #xx:8,exr pop.w rn pop.l ern push.w rn push.l ern rotl.b rd rotl.b #2, rd rotl.w rd rotl.w #2, rd rotl.l erd rotl.l #2, erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion neg nop not or orc pop push rotl b w l ? b w l b b w w l l b b w l w l b b w w l l 0 0 0 0 0 erd erd erd erd erd 1 1 1 0 1 1 1 c 1 7 6 7 0 0 0 6 0 6 0 1 1 1 1 1 1 7 7 7 0 7 7 7 rd 4 9 4 a 1 4 1 d 1 d 1 2 2 2 2 2 2 8 9 b 0 0 1 3 rs 4 rs 4 f 4 7 0 f 0 8 c 9 d b f rd rd 0 rd rd rd rd rd 0 1 rn 0 rn 0 rd rd rd rd imm imm 6 0 6 6 4 4 d d ers 0 0 0 erd ern ern 0 7 f imm imm imm
777 table a.2 instruction codes (cont) rotr.b rd rotr.b #2, rd rotr.w rd rotr.w #2, rd rotr.l erd rotr.l #2, erd rotxl.b rd rotxl.b #2, rd rotxl.w rd rotxl.w #2, rd rotxl.l erd rotxl.l #2, erd rotxr.b rd rotxr.b #2, rd rotxr.w rd rotxr.w #2, rd rotxr.l erd rotxr.l #2, erd rte rts shal.b rd shal.b #2, rd shal.w rd shal.w #2, rd shal.l erd shal.l #2, erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion rotr rotxl rotxr rte rts shal b b w w l l b b w w l l b b w w l l ? ? b b w w l l 0 0 0 0 0 0 0 0 erd erd erd erd erd erd erd erd 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 5 1 1 1 1 1 1 3 3 3 3 3 3 2 2 2 2 2 2 3 3 3 3 3 3 6 4 0 0 0 0 0 0 8 c 9 d b f 0 4 1 5 3 7 0 4 1 5 3 7 7 7 8 c 9 d b f rd rd rd rd rd rd rd rd rd rd rd rd 0 0 rd rd rd rd
778 table a.2 instruction codes (cont) shar.b rd shar.b #2, rd shar.w rd shar.w #2, rd shar.l erd shar.l #2, erd shll.b rd shll.b #2, rd shll.w rd shll.w #2, rd shll.l erd shll.l #2, erd shlr.b rd shlr.b #2, rd shlr.w rd shlr.w #2, rd shlr.l erd shlr.l #2, erd sleep stc.b ccr,rd stc.b exr,rd stc.w ccr,@erd stc.w exr,@erd stc.w ccr,@(d:16,erd) stc.w exr,@(d:16,erd) stc.w ccr,@(d:32,erd) stc.w exr,@(d:32,erd) stc.w ccr,@-erd stc.w exr,@-erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion shar shll shlr sleep stc b b w w l l b b w w l l b b w w l l ? b b w w w w w w w w 0 0 0 0 0 0 erd erd erd erd erd erd 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 8 c 9 d b f 0 4 1 5 3 7 0 4 1 5 3 7 8 0 1 4 4 4 4 4 4 4 4 rd rd rd rd rd rd rd rd rd rd rd rd 0 rd rd 0 1 0 1 0 1 0 1 erd erd erd erd erd erd erd erd 1 1 1 1 0 0 1 1 6 6 6 6 7 7 6 6 9 9 f f 8 8 d d 0 0 0 0 0 0 0 0 6 6 b b a a 0 0 disp disp disp disp
779 table a.2 instruction codes (cont) stc.w ccr,@aa:16 stc.w exr,@aa:16 stc.w ccr,@aa:32 stc.w exr,@aa:32 stm.l (ern-ern+1), @-sp stm.l (ern-ern+2), @-sp stm.l (ern-ern+3), @-sp stmac mach,erd stmac macl,erd sub.b rs,rd sub.w #xx:16,rd sub.w rs,rd sub.l #xx:32,erd sub.l ers,erd subs #1,erd subs #2,erd subs #4,erd subx #xx:8,rd subx rs,rd tas @erd trapa #x:2 xor.b #xx:8,rd xor.b rs,rd xor.w #xx:16,rd xor.w rs,rd xor.l #xx:32,erd xor.l ers,erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion stc stm stmac sub subs subx tas trapa xor w w w w l l l l l b w w l l l l l b b b ? b b w w l l 1 00 ers imm 0 0 0 0 0 0 erd erd erd erd erd erd erd ers 0 0 0 0 ern ern ern erd 0 0 0 0 0 0 0 0 0 1 7 1 7 1 1 1 1 b 1 0 5 d 1 7 6 7 0 1 1 1 1 1 1 1 8 9 9 a a b b b rd e 1 7 rd 5 9 5 a 1 4 4 4 4 1 2 3 rs 3 rs 3 0 8 9 rs e rs 5 rs 5 f 0 1 0 1 0 0 0 rd rd rd rd 0 0 rd rd rd 0 6 6 6 6 6 6 6 7 6 b b b b d d d b 5 8 8 a a f f f 0 0 0 0 c abs abs abs abs imm imm imm imm imm imm cannot be used with the h8s/2148 series and h8s/2144 series.
780 table a.2 instruction codes (cont) xorc #xx:8,ccr xorc #xx:8,exr mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion xorc b b 0 0 5 1 4 1 0 5 imm imm note: bit 7 of the 4th byte of the mov.l ers, @ (d:32, erd) instruction can be either 0 or 1. legend address registers 32-bit registers register field general register register field general register register field general register 000 001 ? ? ? 111 er0 er1 ? ? ? er7 0000 0001 ? ? ? 0111 1000 1001 ? ? ? 1111 r0 r1 ? ? ? r7 e0 e1 ? ? ? e7 0000 0001 ? ? ? 0111 1000 1001 ? ? ? 1111 r0h r1h ? ? ? r7h r0l r1l ? ? ? r7l 16-bit register 8-bit register imm: abs: disp: rs, rd, rn: ers, erd, ern, erm: the correspondence between register fields and general registers is shown in the following table. immediate data (2, 3, 8, 16, or 32 bits) absolute address (8, 16, 24, or 32 bits) displacement (8, 16, or 32 bits) register field (4 bits, indicating an 8-bit or 16-bit register. rs, rd, and rn correspond to operand formats rs, rd, and rn, respectively.) register field (3 bits, indicating an address register or 32-bit register. ers, erd, ern, and erm correspond to operand formats ers, erd, ern, and erm, respectively.) *
781 a.3 operation code map table a.3 shows the operation code map. table a.3 operation code map (1) instruction code: 1st byte 2nd byte ah al bh bl instruction when most significant bit of bh is 0. instruction when most significant bit of bh is 1. 0 nop bra mulxu bset ah al 0 1 2 3 4 5 6 7 8 9 a b c d e f 1 brn divxu bnot 2 bhi mulxu bclr 3 bls divxu btst stc stmac ldc ldmac 4 orc or bcc rts or bor bior 6 andc and bne rte and 5 xorc xor bcs bsr xor bxor bixor band biand 7 ldc beq trapa bst bist bld bild 8 bvc mov 9 bvs a bpl jmp b bmi eepmov c bge bsr d blt mov e addx subx bgt jsr f ble mov.b add addx cmp subx or xor and mov add sub mov mov cmp table a.3 (3) ** note: * cannot be used with the h8s/2148 series and h8s/2144 series. table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2)
782 table a.3 operation code map (2) instruction code: 1st byte 2nd byte ah al bh bl 01 0a 0b 0f 10 11 12 13 17 1a 1b 1f 58 6a 79 7a 0 mov inc adds daa dec subs das bra mov mov mov shll shlr rotxl rotxr not 1 ldm brn add add 2 bhi mov cmp cmp 3 stm not bls sub sub 4 shll shlr rotxl rotxr bcc movfpe or or 5 inc extu dec bcs xor xor 6 mac bne and and 7 inc shll shlr rotxl rotxr extu dec beq ldc stc 8 sleep bvc mov adds shal shar rotl rotr neg subs 9 bvs a clrmac bpl mov b neg bmi add mov sub cmp c shal shar rotl rotr bge movtpe d inc exts dec blt e tas bgt f inc shal shar rotl rotr exts dec ble bh ah al * * note: * cannot be used with the h8s/2148 series and h8s/2144 series. * * table a.3 (4) table a.3 (4) table a.3 (3) table a.3 (3) table a.3 (3)
783 table a.3 operation code map (3) instruction code: 1st byte 2nd byte ah al bh bl 3rd byte 4th byte ch cl dh dl instruction when most significant bit of dh is 0. instruction when most significant bit of dh is 1. notes: 1. r is the register specification field. 2. aa is the absolute address specification. ah al bh bl ch cl 01c05 01d05 01f06 7cr06 * 1 7cr07 * 1 7dr06 * 1 7dr07 * 1 7eaa6 * 2 7eaa7 * 2 7faa6 * 2 7faa7 * 2 0 mulxs bset bset bset bset 1 divxs bnot bnot bnot bnot 2 mulxs bclr bclr bclr bclr 3 divxs btst btst btst btst 4 or 5 xor 6 and 789abcdef bor bior bxor bixor band biand bld bild bst bist bor bior bxor bixor band biand bld bild bst bist
784 table a.3 operation code map (4) instruction code: 1st byte 2nd byte ah al bh bl 3rd byte 4th byte ch cl dh dl instruction when most significant bit of fh is 0. instruction when most significant bit of fh is 1. 5th byte 6th byte eh el fh fl instruction code: 1st byte 2nd byte ah al bh bl 3rd byte 4th byte ch cl dh dl indicates case where msb of hh is 0. indicates case where msb of hh is 1. note: * aa is the absolute address specification. 5th byte 6th byte eh el fh fl 7th byte 8th byte gh gl hh hl 6a10aaaa6 * 6a10aaaa7 * 6a18aaaa6 * 6a18aaaa7 * ahalbhblchcldhdleh el 0 bset 1 bnot 2 bclr 3 btst bor bior bxor bixor band biand bld bild bst bist 456789abcdef 6a30aaaaaaaa6 * 6a30aaaaaaaa7 * 6a38aaaaaaaa6 * 6a38aaaaaaaa7 * ahalbhbl ... fhflgh gl 0 bset 1 bnot 2 bclr 3 btst bor bior bxor bixor band biand bld bild bst bist 456789abcdef
785 a.4 number of states required for execution the tables in this section can be used to calculate the number of states required for instruction execution by the h8s/2000 cpu. table a.5 shows the number of instruction fetch, data read/write, and other cycles occurring in each instruction, and table a.4 shows the number of states required per cycle according to the bus size. the number of states required for execution of an instruction can be calculated from these two tables as follows: number of states = i s i + j s j + k s k + l s l + m s m + n s n examples of calculation of number of states required for execution examples: advanced mode, stack located in external address space, on-chip supporting modules accessed in two states with 8-bit bus width, external devices accessed in three states with one wait state and 16-bit bus width. 1. bset #0,@ffffc7:8 from table a.5, i = l = 2 and j = k = m = n = 0 from table a.4, s i = 4 and s l = 2 number of states = 2 4 + 2 2 = 12 2. jsr @@30 from table a.5, i = j = k = 2 and l = m = n = 0 from table a.4, s i = s j = s k = 4 number of states = 2 4 + 2 4 + 2 4 = 24
786 table a.4 number of states per cycle access conditions on-chip external device supporting module 8-bit bus 16-bit bus cycle on-chip memory 8-bit bus 16-bit bus 2-state access 3-state access 2-state access 3-state access instruction fetch s i 1 4 2 4 6 + 2m 2 3 + m branch address fetch s j stack operation s k byte data access s l 2 2 3 + m word data access s m 4 4 6 + 2m internal operation s n 1111111 legend: m: number of wait states inserted into external device access
787 table a.5 number of cycles per instruction instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n add add.b #xx:8,rd 1 add.b rs,rd 1 add.w #xx:16,rd 2 add.w rs,rd 1 add.l #xx:32,erd 3 add.l ers,erd 1 adds adds #1/2/4,erd 1 addx addx #xx:8,rd 1 addx rs,rd 1 and and.b #xx:8,rd 1 and.b rs,rd 1 and.w #xx:16,rd 2 and.w rs,rd 1 and.l #xx:32,erd 3 and.l ers,erd 2 andc andc #xx:8,ccr 1 andc #xx:8,exr 2 band band #xx:3,rd 1 band #xx:3,@erd 2 1 band #xx:3,@aa:8 2 1 band #xx:3,@aa:16 3 1 band #xx:3,@aa:32 4 1 bcc bra d:8 (bt d:8) 2 brn d:8 (bf d:8) 2 bhi d:8 2 bls d:8 2 bcc d:8 (bhs d:8) 2 bcs d:8 (blo d:8) 2 bne d:8 2 beq d:8 2 bvc d:8 2 bvs d:8 2 bpl d:8 2 bmi d:8 2 bge d:8 2 blt d:8 2
788 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n bcc bgt d:8 2 ble d:8 2 bra d:16 (bt d:16) 2 1 brn d:16 (bf d:16) 2 1 bhi d:16 2 1 bls d:16 2 1 bcc d:16 (bhs d:16) 2 1 bcs d:16 (blo d:16) 2 1 bne d:16 2 1 beq d:16 2 1 bvc d:16 2 1 bvs d:16 2 1 bpl d:16 2 1 bmi d:16 2 1 bge d:16 2 1 blt d:16 2 1 bgt d:16 2 1 ble d:16 2 1 bclr bclr #xx:3,rd 1 bclr #xx:3,@erd 2 2 bclr #xx:3,@aa:8 2 2 bclr #xx:3,@aa:16 3 2 bclr #xx:3,@aa:32 4 2 bclr rn,rd 1 bclr rn,@erd 2 2 bclr rn,@aa:8 2 2 bclr rn,@aa:16 3 2 bclr rn,@aa:32 4 2 biand biand #xx:3,rd 1 biand #xx:3,@erd 2 1 biand #xx:3,@aa:8 2 1 biand #xx:3,@aa:16 3 1 biand #xx:3,@aa:32 4 1
789 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n bild bild #xx:3,rd 1 bild #xx:3,@erd 2 1 bild #xx:3,@aa:8 2 1 bild #xx:3,@aa:16 3 1 bild #xx:3,@aa:32 4 1 bior bior #xx:8,rd 1 bior #xx:8,@erd 2 1 bior #xx:8,@aa:8 2 1 bior #xx:8,@aa:16 3 1 bior #xx:8,@aa:32 4 1 bist bist #xx:3,rd 1 bist #xx:3,@erd 2 2 bist #xx:3,@aa:8 2 2 bist #xx:3,@aa:16 3 2 bist #xx:3,@aa:32 4 2 bixor bixor #xx:3,rd 1 bixor #xx:3,@erd 2 1 bixor #xx:3,@aa:8 2 1 bixor #xx:3,@aa:16 3 1 bixor #xx:3,@aa:32 4 1 bld bld #xx:3,rd 1 bld #xx:3,@erd 2 1 bld #xx:3,@aa:8 2 1 bld #xx:3,@aa:16 3 1 bld #xx:3,@aa:32 4 1 bnot bnot #xx:3,rd 1 bnot #xx:3,@erd 2 2 bnot #xx:3,@aa:8 2 2 bnot #xx:3,@aa:16 3 2 bnot #xx:3,@aa:32 4 2 bnot rn,rd 1 bnot rn,@erd 2 2 bnot rn,@aa:8 2 2 bnot rn,@aa:16 3 2 bnot rn,@aa:32 4 2
790 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n bor bor #xx:3,rd 1 bor #xx:3,@erd 2 1 bor #xx:3,@aa:8 2 1 bor #xx:3,@aa:16 3 1 bor #xx:3,@aa:32 4 1 bset bset #xx:3,rd 1 bset #xx:3,@erd 2 2 bset #xx:3,@aa:8 2 2 bset #xx:3,@aa:16 3 2 bset #xx:3,@aa:32 4 2 bset rn,rd 1 bset rn,@erd 2 2 bset rn,@aa:8 2 2 bset rn,@aa:16 3 2 bset rn,@aa:32 4 2 bsr bsr d:8 normal 2 1 advanced 2 2 bsr d:16 normal 2 1 1 advanced 2 2 1 bst bst #xx:3,rd 1 bst #xx:3,@erd 2 2 bst #xx:3,@aa:8 2 2 bst #xx:3,@aa:16 3 2 bst #xx:3,@aa:32 4 2 btst btst #xx:3,rd 1 btst #xx:3,@erd 2 1 btst #xx:3,@aa:8 2 1 btst #xx:3,@aa:16 3 1 btst #xx:3,@aa:32 4 1 btst rn,rd 1 btst rn,@erd 2 1 btst rn,@aa:8 2 1 btst rn,@aa:16 3 1 btst rn,@aa:32 4 1
791 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n bxor bxor #xx:3,rd 1 bxor #xx:3,@erd 2 1 bxor #xx:3,@aa:8 2 1 bxor #xx:3,@aa:16 3 1 bxor #xx:3,@aa:32 4 1 clrmac clrmac cannot be used with the h8s/2148 series and h8s/2144 series. cmp cmp.b #xx:8,rd 1 cmp.b rs,rd 1 cmp.w #xx:16,rd 2 cmp.w rs,rd 1 cmp.l #xx:32,erd 3 cmp.l ers,erd 1 daa daa rd 1 das das rd 1 dec dec.b rd 1 dec.w #1/2,rd 1 dec.l #1/2,erd 1 divxs divxs.b rs,rd 2 11 divxs.w rs,erd 2 19 divxu divxu.b rs,rd 1 11 divxu.w rs,erd 1 19 eepmov eepmov.b 2 2n+2 * 2 eepmov.w 2 2n+2 * 2 exts exts.w rd 1 exts.l erd 1 extu extu.w rd 1 extu.l erd 1 inc inc.b rd 1 inc.w #1/2,rd 1 inc.l #1/2,erd 1 jmp jmp @ern 2 jmp @aa:24 2 1 jmp @@aa:8 normal 2 1 1 advanced 2 2 1
792 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n jsr jsr @ern normal 2 1 advanced 2 2 jsr @aa:24 normal 2 1 1 advanced 2 2 1 jsr @@aa:8 normal 2 1 1 advanced 2 2 2 ldc ldc #xx:8,ccr 1 ldc #xx:8,exr 2 ldc rs,ccr 1 ldc rs,exr 1 ldc @ers,ccr 2 1 ldc @ers,exr 2 1 ldc @(d:16,ers),ccr 3 1 ldc @(d:16,ers),exr 3 1 ldc @(d:32,ers),ccr 5 1 ldc @(d:32,ers),exr 5 1 ldc @ers+,ccr 2 1 1 ldc @ers+,exr 2 1 1 ldc @aa:16,ccr 3 1 ldc @aa:16,exr 3 1 ldc @aa:32,ccr 4 1 ldc @aa:32,exr 4 1 ldm ldm.l @sp+, (ern-ern+1) 2 4 1 ldm.l @sp+, (ern-ern+2) 2 6 1 ldm.l @sp+, (ern-ern+3) 2 8 1 ldmac ldmac ers, mach cannot be used with the h8s/2148 series and h8s/2144 series. ldmac ers, macl mac mac @ern+, @erm+ mov mov.b #xx:8,rd 1 mov.b rs,rd 1 mov.b @ers,rd 1 1 mov.b @(d:16,ers),rd 2 1 mov.b @(d:32,ers),rd 4 1 mov.b @ers+,rd 1 1 1 mov.b @aa:8,rd 1 1 mov.b @aa:16,rd 2 1
793 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n mov mov.b @aa:32,rd 3 1 mov.b rs,@erd 1 1 mov.b rs,@(d:16,erd) 2 1 mov.b rs,@(d:32,erd) 4 1 mov.b rs,@-erd 1 1 1 mov.b rs,@aa:8 1 1 mov.b rs,@aa:16 2 1 mov.b rs,@aa:32 3 1 mov.w #xx:16,rd 2 mov.w rs,rd 1 mov.w @ers,rd 1 1 mov.w @(d:16,ers),rd 2 1 mov.w @(d:32,ers),rd 4 1 mov.w @ers+,rd 1 1 1 mov.w @aa:16,rd 2 1 mov.w @aa:32,rd 3 1 mov.w rs,@erd 1 1 mov.w rs,@(d:16,erd) 2 1 mov.w rs,@(d:32,erd) 4 1 mov.w rs,@-erd 1 1 1 mov.w rs,@aa:16 2 1 mov.w rs,@aa:32 3 1 mov.l #xx:32,erd 3 mov.l ers,erd 1 mov.l @ers,erd 2 2 mov.l @(d:16,ers),erd 3 2 mov.l @(d:32,ers),erd 5 2 mov.l @ers+,erd 2 2 1 mov.l @aa:16,erd 3 2 mov.l @aa:32,erd 4 2 mov.l ers,@erd 2 2 mov.l ers,@(d:16,erd) 3 2 mov.l ers,@(d:32,erd) 5 2 mov.l ers,@-erd 2 2 1 mov.l ers,@aa:16 3 2 mov.l ers,@aa:32 4 2
794 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n movfpe movfpe @:aa:16,rd cannot be used with the h8s/2148 series and h8s/2144 series. movtpe movtpe rs,@:aa:16 mulxs mulxs.b rs,rd 2 11 mulxs.w rs,erd 2 19 mulxu mulxu.b rs,rd 1 11 mulxu.w rs,erd 1 19 neg neg.b rd 1 neg.w rd 1 neg.l erd 1 nop nop 1 not not.b rd 1 not.w rd 1 not.l erd 1 or or.b #xx:8,rd 1 or.b rs,rd 1 or.w #xx:16,rd 2 or.w rs,rd 1 or.l #xx:32,erd 3 or.l ers,erd 2 orc orc #xx:8,ccr 1 orc #xx:8,exr 2 pop pop.w rn 1 1 1 pop.l ern 2 2 1 push push.w rn 1 1 1 push.l ern 2 2 1 rotl rotl.b rd 1 rotl.b #2,rd 1 rotl.w rd 1 rotl.w #2,rd 1 rotl.l erd 1 rotl.l #2,erd 1
795 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n rotr rotr.b rd 1 rotr.b #2,rd 1 rotr.w rd 1 rotr.w #2,rd 1 rotr.l erd 1 rotr.l #2,erd 1 rotxl rotxl.b rd 1 rotxl.b #2,rd 1 rotxl.w rd 1 rotxl.w #2,rd 1 rotxl.l erd 1 rotxl.l #2,erd 1 rotxr rotxr.b rd 1 rotxr.b #2,rd 1 rotxr.w rd 1 rotxr.w #2,rd 1 rotxr.l erd 1 rotxr.l #2,erd 1 rte rte 2 2/3 * 1 1 rts rts normal 2 1 1 advanced 2 2 1 shal shal.b rd 1 shal.b #2,rd 1 shal.w rd 1 shal.w #2,rd 1 shal.l erd 1 shal.l #2,erd 1 shar shar.b rd 1 shar.b #2,rd 1 shar.w rd 1 shar.w #2,rd 1 shar.l erd 1 shar.l #2,erd 1
796 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n shll shll.b rd 1 shll.b #2,rd 1 shll.w rd 1 shll.w #2,rd 1 shll.l erd 1 shll.l #2,erd 1 shlr shlr.b rd 1 shlr.b #2,rd 1 shlr.w rd 1 shlr.w #2,rd 1 shlr.l erd 1 shlr.l #2,erd 1 sleep sleep 1 1 stc stc.b ccr,rd 1 stc.b exr,rd 1 stc.w ccr,@erd 2 1 stc.w exr,@erd 2 1 stc.w ccr,@(d:16,erd) 3 1 stc.w exr,@(d:16,erd) 3 1 stc.w ccr,@(d:32,erd) 5 1 stc.w exr,@(d:32,erd) 5 1 stc.w ccr,@-erd 2 1 1 stc.w exr,@-erd 2 1 1 stc.w ccr,@aa:16 3 1 stc.w exr,@aa:16 3 1 stc.w ccr,@aa:32 4 1 stc.w exr,@aa:32 4 1 stm stm.l (ern-ern+1),@-sp 2 4 1 stm.l (ern-ern+2),@-sp 2 6 1 stm.l (ern-ern+3),@-sp 2 8 1 sub sub.b rs,rd 1 sub.w #xx:16,rd 2 sub.w rs,rd 1 sub.l #xx:32,erd 3 sub.l ers,erd 1
797 table a.5 number of cycles per instruction (cont) instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n subs subs #1/2/4,erd 1 subx subx #xx:8,rd 1 subx rs,rd 1 tas tas @erd 2 2 trapa trapa #x:2 normal 2 1 2/3 * 1 2 advanced 2 2 2/3 * 1 2 xor xor.b #xx:8,rd 1 xor.b rs,rd 1 xor.w #xx:16,rd 2 xor.w rs,rd 1 xor.l #xx:32,erd 3 xor.l ers,erd 2 xorc xorc #xx:8,ccr 1 xorc #xx:8,exr 2 notes: 1. 2 when exr is invalid, 3 when valid. 2. when n bytes of data are transferred.
798 a.5 bus states during instruction execution table a.6 indicates the types of cycles that occur during instruction execution by the cpu. see table a.4 for the number of states per cycle. how to read the table: instruction jmp@aa:24 r:w 2nd internal operation, 2 state r:w ea 123 4 567 8 end of instruction order of execution read effective address (word-size read) no read or write read 2nd word of current instruction (word-size read) legend: r:b byte-size read r:w word-size read w:b byte-size write w:w word-size write :m transfer of the bus is not performed immediately after this cycle 2nd address of 2nd word (3rd and 4th bytes) 3rd address of 3rd word (5th and 6th bytes) 4th address of 4th word (7th and 8th bytes) 5th address of 5th word (9th and 10th bytes) next start address of instruction following executing instruction ea effective address vec vector address
799 figure a.1 shows timing waveforms for the address bus and the 5' , +:5 , and /:5 signals during execution of the above instruction with an 8-bit bus, using three-state access with no wait states. address bus rd hwr , lwr r:w 2nd fetching 3rd byte of instruction fetching 4th byte of instruction fetching 1st byte of branch instruction fetching 2nd byte of branch instruction r:w ea high level internal operation figure a.1 address bus, 5' 5' , +:5 +:5 , and /:5 /:5 timing (8-bit bus, three-state access, no wait states)
800 table a.6 instruction execution cycle instruction 123456789 add.b #xx:8,rd r:w next add.b rs,rd r:w next add.w #xx:16,rd r:w 2nd r:w next add.w rs,rd r:w next add.l #xx:32,erd r:w 2nd r:w 3rd r:w next add.l ers,erd r:w next adds #1/2/4,erd r:w next addx #xx:8,rd r:w next addx rs,rd r:w next and.b #xx:8,rd r:w next and.b rs,rd r:w next and.w #xx:16,rd r:w 2nd r:w next and.w rs,rd r:w next and.l #xx:32,erd r:w 2nd r:w 3rd r:w next and.l ers,erd r:w 2nd r:w next andc #xx:8,ccr r:w next andc #xx:8,exr r:w 2nd r:w next band #xx:3,rd r:w next band #xx:3,@erd r:w 2nd r:b ea r:w:m next band #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next band #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next band #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bra d:8 (bt d:8) r:w next r:w ea brn d:8 (bf d:8) r:w next r:w ea bhi d:8 r:w next r:w ea bls d:8 r:w next r:w ea bcc d:8 (bhs d:8) r:w next r:w ea bcs d:8 (blo d:8) r:w next r:w ea bne d:8 r:w next r:w ea beq d:8 r:w next r:w ea bvc d:8 r:w next r:w ea bvs d:8 r:w next r:w ea bpl d:8 r:w next r:w ea
801 table a.6 instruction execution cycle (cont) instruction 123456789 bmi d:8 r:w next r:w ea bge d:8 r:w next r:w ea blt d:8 r:w next r:w ea bgt d:8 r:w next r:w ea ble d:8 r:w next r:w ea bra d:16 (bt d:16) r:w 2nd internal operation, 1 state r:w ea brn d:16 (bf d:16) r:w 2nd internal operation, 1 state r:w ea bhi d:16 r:w 2nd internal operation, 1 state r:w ea bls d:16 r:w 2nd internal operation, 1 state r:w ea bcc d:16 (bhs d:16) r:w 2nd internal operation, 1 state r:w ea bcs d:16 (blo d:16) r:w 2nd internal operation, 1 state r:w ea bne d:16 r:w 2nd internal operation, 1 state r:w ea beq d:16 r:w 2nd internal operation, 1 state r:w ea bvc d:16 r:w 2nd internal operation, 1 state r:w ea bvs d:16 r:w 2nd internal operation, 1 state r:w ea bpl d:16 r:w 2nd internal operation, 1 state r:w ea bmi d:16 r:w 2nd internal operation, 1 state r:w ea bge d:16 r:w 2nd internal operation, 1 state r:w ea
802 table a.6 instruction execution cycle (cont) instruction 123456789 blt d:16 r:w 2nd internal operation, 1 state r:w ea bgt d:16 r:w 2nd internal operation, 1 state r:w ea ble d:16 r:w 2nd internal operation, 1 state r:w ea bclr #xx:3,rd r:w next bclr #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bclr #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bclr#xx:3,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bclr#xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bclr rn,rd r:w next bclr rn,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bclr rn,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bclr rn,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bclr rn,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea biand #xx:3,rd r:w next biand #xx:3, @erd r:w 2nd r:b ea r:w:m next biand #xx:3, @aa:8 r:w 2nd r:b ea r:w:m next biand #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next biand #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bild #xx:3,rd r:w next bild #xx:3,@erd r:w 2nd r:b ea r:w:m next bild #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bild #xx:3,@aa:16 r:w 2nd r:w 3rd r:b: ea r:w:m next
803 table a.6 instruction execution cycle (cont) instruction 123456789 bild #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bior #xx:3,rd r:w next bior #xx:3,@erd r:w 2nd r:b ea r:w:m next bior #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bior #xx:3,@aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bior #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bist #xx:3,rd r:w next bist #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bist #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bist #xx:3,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bist #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bixor #xx:3,rd r:w next bixor #xx:3, @erd r:w 2nd r:b ea r:w:m next bixor #xx:3, @aa:8 r:w 2nd r:b ea r:w:m next bixor #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bixor #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bld #xx:3,rd r:w next bld #xx:3,@erd r:w 2nd r:b ea r:w:m next bld #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bld #xx:3,@aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bld #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bnot #xx:3,rd r:w next bnot #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea
804 table a.6 instruction execution cycle (cont) instruction 123456789 bnot #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bnot #xx:3, @aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bnot #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bnot rn,rd r:w next bnot rn,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bnot rn,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bnot rn,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bnot rn,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bor #xx:3,rd r:w next bor #xx:3,@erd r:w 2nd r:b ea r:w:m next bor #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bor #xx:3,@aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bor #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w next bset #xx:3,rd r:w next bset #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bset #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bset #xx:3, @aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bset #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bset rn,rd r:w next bset rn,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bset rn,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bset rn,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bset rn,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea
805 table a.6 instruction execution cycle (cont) instruction 123456789 bsr d:8 advanced r:w next r:w ea w:w:m stack (h) w:w stack (l) bsr d:16 advanced r:w 2nd internal operation, 1 state r:w ea w:w:m stack (h) w:w stack (l) bst #xx:3,rd r:w next bst #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bst #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bst #xx:3,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bst #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea btst #xx:3,rd r:w next btst #xx:3,@erd r:w 2nd r:b ea r:w:m next btst #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next btst #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next btst #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next btst rn,rd r:w next btst rn,@erd r:w 2nd r:b ea r:w:m next btst rn,@aa:8 r:w 2nd r:b ea r:w:m next btst rn,@aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next btst rn,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bxor #xx:3,rd r:w next bxor #xx:3,@erd r:w 2nd r:b ea r:w:m next bxor #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bxor #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bxor #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next clrmac cannot be used in the h8s/2148 series and h8s/2144 series
806 table a.6 instruction execution cycle (cont) instruction 123456789 cmp.b #xx:8,rd r:w next cmp.b rs,rd r:w next cmp.w #xx:16,rd r:w 2nd r:w next cmp.w rs,rd r:w next cmp.l #xx:32,erd r:w 2nd r:w 3rd r:w next cmp.l ers,erd r:w next daa rd r:w next das rd r:w next dec.b rd r:w next dec.w #1/2,rd r:w next dec.l #1/2,erd r:w next divxs.b rs,rd r:w 2nd r:w next internal operation, 11 states divxs.w rs,erd r:w 2nd r:w next internal operation, 19 states divxu.b rs,rd r:w next internal operation, 11 states divxu.w rs,erd r:w next internal operation, 19 states eepmov.b r:w 2nd r:b eas * 1 r:b ead * 1 r:b eas * 2 w:b ead * 2 r:w next eepmov.w r:w 2nd r:b eas * 1 r:b ead * 1 r:b eas * 2 w:b ead * 2 r:w next exts.w rd r:w next ? repeated n times * 2 ? exts.l erd r:w next extu.w rd r:w next extu.l erd r:w next inc.b rd r:w next inc.w #1/2,rd r:w next inc.l #1/2,erd r:w next jmp @ern r:w next r:w ea jmp @aa:24 r:w 2nd internal operation, 1 state r:w ea jmp @@aa:8 advanced r:w next r:w:m aa:8 r:w aa:8 internal operation, 1 state r:w ea jsr @ern advanced r:w next r:w ea w:w:m stack (h) w:w stack (l) jsr @aa:24 advanced r:w 2nd internal operation, 1 state r:w ea w:w:m stack (h) w:w stack (l) jsr @@aa:8 advanced r:w next r:w:m aa:8 r:w aa:8 w:w:m stack (h) w:w stack (l) r:w ea
807 table a.6 instruction execution cycle (cont) instruction 123456789 ldc #xx:8,ccr r:w next ldc #xx:8,exr r:w 2nd r:w next ldc rs,ccr r:w next ldc rs,exr r:w next ldc @ers,ccr r:w 2nd r:w next r:w ea ldc @ers,exr r:w 2nd r:w next r:w ea ldc@(d:16,ers), ccr r:w 2nd r:w 3rd r:w next r:w ea ldc@(d:16,ers), exr r:w 2nd r:w 3rd r:w next r:w ea ldc@(d:32,ers), ccr r:w 2nd r:w 3rd r:w 4th r:w 5th r:w next r:w ea ldc@(d:32,ers), exr r:w 2nd r:w 3rd r:w 4th r:w 5th r:w next r:w ea ldc @ers+,ccr r:w 2nd r:w next internal operation, 1 state r:w ea ldc @ers+,exr r:w 2nd r:w next internal operation, 1 state r:w ea ldc @aa:16,ccr r:w 2nd r:w 3rd r:w next r:w ea ldc @aa:16,exr r:w 2nd r:w 3rd r:w next r:w ea ldc @aa:32,ccr r:w 2nd r:w 3rd r:w 4th r:w next r:w ea ldc @aa:32,exr r:w 2nd r:w 3rd r:w 4th r:w next r:w ea ldm.l @sp+, (ern-ern+1) r:w 2nd r:w:m next internal operation, 1 state r:w:m stack (h) * 3 r:w stack (l) * 3 ldm.l @sp+, (ern-ern+2) r:w 2nd r:w:m next internal operation, 1 state r:w:m stack (h) * 3 r:w stack (l) * 3 ldm.l @sp+, (ern-ern+3) r:w 2nd r:w:m next internal operation, 1 state r:w:m stack (h) * 3 r:w stack (l) * 3 ldmac ers,mach cannot be used in the h8s/2148 series and h8s/2144 series ldmac ers,macl mac @ern+, @erm+ mov.b #xx:8,rd r:w next mov.b rs,rd r:w next mov.b @ers,rd r:w next r:b ea mov.b @(d:16,ers),rd r:w 2nd r:w next r:b ea
808 table a.6 instruction execution cycle (cont) instruction 123456789 mov.b @(d:32,ers),rd r:w 2nd r:w 3rd r:w 4th r:w next r:b ea mov.b @ers+,rd r:w next internal operation, 1 state r:b ea mov.b @aa:8,rd r:w next r:b ea mov.b @aa:16,rd r:w 2nd r:w next r:b ea mov.b @aa:32,rd r:w 2nd r:w 3rd r:w next r:b ea mov.b rs,@erd r:w next w:b ea mov.b rs, @(d:16,erd) r:w 2nd r:w next w:b ea mov.b rs, @(d:32,erd) r:w 2nd r:w 3rd r:w 4th r:w next w:b ea mov.b rs,@-erd r:w next internal operation, 1 state w:b ea mov.b rs,@aa:8 r:w next w:b ea mov.b rs,@aa:16 r:w 2nd r:w next w:b ea mov.b rs,@aa:32 r:w 2nd r:w 3rd r:w next w:b ea mov.w #xx:16,rd r:w 2nd r:w next mov.w rs,rd r:w next mov.w @ers,rd r:w next r:w ea mov.w @(d:16,ers),rd r:w 2nd r:w next r:w ea mov.w @(d:32,ers),rd r:w 2nd r:w 3rd r:w 4th r:w next r:w ea mov.w @ers+,rd r:w next internal operation, 1 state r:w ea mov.w @aa:16,rd r:w 2nd r:w next r:w ea mov.w @aa:32,rd r:w 2nd r:w 3rd r:w next r:b ea mov.w rs,@erd r:w next w:w ea mov.w rs, @(d:16,erd) r:w 2nd r:w next w:w ea mov.w rs, @(d:32,erd) r:w 2nd r:w 3rd r:w 4th r:w next w:w ea mov.w rs,@-erd r:w next internal operation, 1 state w:w ea mov.w rs,@aa:16 r:w 2nd r:w next w:w ea mov.w rs,@aa:32 r:w 2nd r:w 3rd r:w next w:w ea
809 table a.6 instruction execution cycle (cont) instruction 123456789 mov.l #xx:32,erd r:w 2nd r:w 3rd r:w next mov.l ers,erd r:w next mov.l @ers,erd r:w 2nd r:w:m next r:w:m ea r:w ea+2 mov.l @(d:16,ers),erd r:w 2nd r:w:m 3rd r:w next r:w:m ea r:w ea+2 mov.l @(d:32,ers),erd r:w 2nd r:w:m 3rd r:w:m 4th r:w 5th r:w next r:w:m ea r:w ea+2 mov.l @ers+, erd r:w 2nd r:w:m next internal operation, 1 state r:w:m ea r:w ea+2 mov.l @aa:16, erd r:w 2nd r:w:m 3rd r:w next r:w:m ea r:w ea+2 mov.l @aa:32, erd r:w 2nd r:w:m 3rd r:w 4th r:w next r:w:m ea r:w ea+2 mov.l ers,@erd r:w 2nd r:w:m next w:w:m ea w:w ea+2 mov.l ers, @(d:16,erd) r:w 2nd r:w:m 3rd r:w next w:w:m ea w:w ea+2 mov.l ers, @(d:32,erd) r:w 2nd r:w:m 3rd r:w:m 4th r:w 5th r:w next w:w:m ea w:w ea+2 mov.l ers,@-erd r:w 2nd r:w:m next internal operation, 1 state w:w:m ea w:w ea+2 mov.l ers, @aa:16 r:w 2nd r:w:m 3rd r:w next w:w:m ea w:w ea+2 mov.l ers, @aa:32 r:w 2nd r:w:m 3rd r:w 4th r:w next w:w:m ea w:w ea+2 movfpe @aa:16,rd cannot be used in the h8s/2148 series and h8s/2144 series movtpe rs,@aa:16 mulxs.b rs,rd r:w 2nd r:w next internal operation, 11 states mulxs.w rs,erd r:w 2nd r:w next internal operation, 19 states mulxu.b rs,rd r:w next internal operation, 11 states mulxu.w rs,erd r:w next internal operation, 19 states neg.b rd r:w next neg.w rd r:w next neg.l erd r:w next nop r:w next not.b rd r:w next not.w rd r:w next
810 table a.6 instruction execution cycle (cont) instruction 123456789 not.l erd r:w next or.b #xx:8,rd r:w next or.b rs,rd r:w next or.w #xx:16,rd r:w 2nd r:w next or.w rs,rd r:w next or.l #xx:32,erd r:w 2nd r:w 3rd r:w next or.l ers,erd r:w 2nd r:w next orc #xx:8,ccr r:w next orc #xx:8,exr r:w 2nd r:w next pop.w rn r:w next internal operation, 1 state r:w ea pop.l ern r:w 2nd r:w:m next internal operation, 1 state r:w:m ea r:w ea+2 push.w rn r:w next internal operation, 1 state w:w ea push.l ern r:w 2nd r:w:m next internal operation, 1 state w:w:m ea w:w ea+2 rotl.b rd r:w next rotl.b #2,rd r:w next rotl.w rd r:w next rotl.w #2,rd r:w next rotl.l erd r:w next rotl.l #2,erd r:w next rotr.b rd r:w next rotr.b #2,rd r:w next rotr.w rd r:w next rotr.w #2,rd r:w next rotr.l erd r:w next rotr.l #2,erd r:w next rotxl.b rd r:w next rotxl.b #2,rd r:w next rotxl.w rd r:w next rotxl.w #2,rd r:w next rotxl.l erd r:w next
811 table a.6 instruction execution cycle (cont) instruction 123456789 rotxl.l #2,erd r:w next rotxr.b rd r:w next rotxr.b #2,rd r:w next rotxr.w rd r:w next rotxr.w #2,rd r:w next rotxr.l erd r:w next rotxr.l #2,erd r:w next rte r:w next r:w stack (exr) r:w stack (h) r:w stack (l) internal operation, 1 state r:w * 4 rts advanced r:w next r:w:m stack (h) r:w stack (l) internal operation, 1 state r:w * 4 shal.b rd r:w next shal.b #2,rd r:w next shal.w rd r:w next shal.w #2,rd r:w next shal.l erd r:w next shal.l #2,erd r:w next shar.b rd r:w next shar.b #2,rd r:w next shar.w rd r:w next shar.w #2,rd r:w next shar.l erd r:w next shar.l #2,erd r:w next shll.b rd r:w next shll.b #2,rd r:w next shll.w rd r:w next shll.w #2,rd r:w next shll.l erd r:w next shll.l #2,erd r:w next shlr.b rd r:w next shlr.b #2,rd r:w next shlr.w rd r:w next shlr.w #2,rd r:w next shlr.l erd r:w next shlr.l #2,erd r:w next
812 table a.6 instruction execution cycle (cont) instruction 123456789 sleep r:w next internal operation :m stc ccr,rd r:w next stc exr,rd r:w next stc ccr,@erd r:w 2nd r:w next w:w ea stc exr,@erd r:w 2nd r:w next w:w ea stc ccr, @(d:16,erd) r:w 2nd r:w 3rd r:w next w:w ea stc exr, @(d:16,erd) r:w 2nd r:w 3rd r:w next w:w ea stc ccr, @(d:32,erd) r:w 2nd r:w 3rd r:w 4th r:w 5th r:w next w:w ea stc exr, @(d:32,erd) r:w 2nd r:w 3rd r:w 4th r:w 5th r:w next w:w ea stc ccr,@-erd r:w 2nd r:w next internal operation, 1 state w:w ea stc exr,@-erd r:w 2nd r:w next internal operation, 1 state w:w ea stc ccr,@aa:16 r:w 2nd r:w 3rd r:w next w:w ea stc exr,@aa:16 r:w 2nd r:w 3rd r:w next w:w ea stc ccr,@aa:32 r:w 2nd r:w 3rd r:w 4th r:w next w:w ea stc exr,@aa:32 r:w 2nd r:w 3rd r:w 4th r:w next w:w ea stm.l (ern-ern+1),@-sp r:w 2nd r:w:m next internal operation, 1 state w:w:m stack (h) * 3 w:w stack (l) * 3 stm.l (ern-ern+2),@-sp r:w 2nd r:w:m next internal operation, 1 state w:w:m stack (h) * 3 w:w stack (l) * 3 stm.l (ern-ern+3),@-sp r:w 2nd r:w:m next internal operation, 1 state w:w:m stack (h) * 3 w:w stack (l) * 3 stmac mach,erd cannot be used in the h8s/2148 series and h8s/2144 series stmac macl,erd sub.b rs,rd r:w next sub.w #xx:16,rd r:w 2nd r:w next sub.w rs,rd r:w next sub.l #xx:32,erd r:w 2nd r:w 3rd r:w next sub.l ers,erd r:w next
813 table a.6 instruction execution cycle (cont) instruction 123456789 subs #1/2/4,erd r:w next subx #xx:8,rd r:w next subx rs,rd r:w next tas @erd r:w 2nd r:w next r:b:m ea w:b ea trapa #x:2 advanced r:w next internal operation, 1 state w:w stack (l) w:w stack (h) w:w stack (exr) r:w:m vec r:w vec+2 internal operation, 1 state r:w * 7 xor.b #xx8,rd r:w next xor.b rs,rd r:w next xor.w #xx:16,rd r:w 2nd r:w next xor.w rs,rd r:w next xor.l #xx:32,erd r:w 2nd r:w 3rd r:w next xor.l ers,erd r:w 2nd r:w next xorc #xx:8,ccr r:w next xorc #xx:8,exr r:w 2nd r:w next reset excep- tion handling advanced r:w:m vec r:w vec+2 internal operation, 1 state r:w * 5 interrupt excep- tion handling advanced r:w * 6 internal operation, 1 state w:w stack (l) w:w stack (h) w:w stack (exr) r:w:m vec r:w vec+2 internal operation, 1 state r:w * 7 notes: 1. eas is the contents of er5. ead is the contents of er6. 2. eas is the contents of er5. ead is the contents of er6. both registers are incremented by 1 after execution of the instruction. n is the initial value of r4l or r4. if n = 0, these bus cycles are not executed. 3. repeated two times to save or restore two registers, three times for three registers, or four times for four registers. 4. start address after return. 5. start address of the program. 6. prefetch address, equal to two plus the pc value pushed onto the stack. in recovery from sleep mode or software standby mode the read operation is replaced by an internal operation. 7. start address of the interrupt-handling routine.
814
815 appendix b internal i/o registers b.1 addresses address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ec00 mra sm1 sm0 dm1 dm0 md1 md0 dts sz dtc 16/32 * to sar h'efff mrb chne disel dar cra crb h'fe80 hicr2 ibfie4 ibfie3 hif 8 h'fe84 idr3 idr7 idr6 idr5 idr4 idr3 idr2 idr1 idr0 h'fe85 odr3 odr7 odr6 odr5 odr4 odr3 odr2 odr1 odr0 h'fe86 str3 dbu dbu dbu dbu c/ ' dbu ibf obf h'fe8c idr4 idr7 idr6 idr5 idr4 idr3 idr2 idr1 idr0 h'fe8d odr4 odr7 odr6 odr5 odr4 odr3 odr2 odr1 odr0 h'fe8e str4 dbu dbu dbu dbu c/ ' dbu ibf obf h'fed8 kbcrh0 kbioe kclki kdi kbfsel kbie kbf per kbs keyboard 8 h'fed9 kbcrl0 kbe kclko kdo rxcr3 rxcr2 rxcr1 rxcr0 buffer h'feda kbbr0 kb7 kb6 kb5 kb4 kb3 kb2 kb1 kb0 controller h'fedc kbcrh1 kbioe kclki kdi kbfsel kbie kbf per kbs h'fedd kbcrl1 kbe kclko kdo rxcr3 rxcr2 rxcr1 rxcr0 h'fede kbbr1 kb7 kb6 kb5 kb4 kb3 kb2 kb1 kb0 h'fee0 kbcrh2 kbioe kclki kdi kbfsel kbie kbf per kbs h'fee1 kbcrl2 kbe kclko kdo rxcr3 rxcr2 rxcr1 rxcr0 h'fee2 kbbr2 kb7 kb6 kb5 kb4 kb3 kb2 kb1 kb0 h'fee4 kbcomp ire ircks2 ircks1 ircks0 kbade kbch2 kbch1 kbch0 irda/ expansion a/d 8 h'fee6 ddcswr swe sw ie if clr3 clr2 clr1 clr0 iic0 8
816 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'fee8 icra icr7 icr6 icr5 icr4 icr3 icr2 icr1 icr0 interrupt 8 h'fee9 icrb icr7 icr6 icr5 icr4 icr3 icr2 icr1 icr0 controller h'feea icrc icr7 icr6 icr5 icr4 icr3 icr2 icr1 icr0 h'feeb isr irq7f irq6f irq5f irq4f irq3f irq2f irq1f irq0f h'feec iscrh irq7scb irq7sca irq6scb irq6sca irq5scb irq5sca irq4scb irq4sca h'feed iscrl irq3scb irq3sca irq2scb irq2sca irq1scb irq1sca irq0scb irq0sca h'feee dtcera dtcea7 dtcea6 dtcea5 dtcea4 dtcea3 dtcea2 dtcea1 dtcea0 dtc 8 h'feef dtcerb dtceb7 dtceb6 dtceb5 dtceb4 dtceb3 dtceb2 dtceb1 dtceb0 h'fef0 dtcerc dtcec7 dtcec6 dtcec5 dtcec4 dtcec3 dtcec2 dtcec1 dtcec0 h'fef1 dtcerd dtced7 dtced6 dtced5 dtced4 dtced3 dtced2 dtced1 dtced0 h'fef2 dtcere dtcee7 dtcee6 dtcee5 dtcee4 dtcee3 dtcee2 dtcee1 dtcee0 h'fef3 dtvecr swdte dtvec6 dtvec5 dtvec4 dtvec3 dtvec2 dtvec1 dtvec0 h'fef4 abrkcr cmf bie interrupt 8 h'fef5 bara a23 a22 a21 a20 a19 a18 a17 a16 controller h'fef6 barb a15 a14 a13 a12 a11 a10 a9 a8 h'fef7 barc a7 a6 a5 a4 a3 a2 a1 h'ff80 flmcr1 fwe swe ev pv e p flash 8 h'ff81 flmcr2 fler esu psu h'ff82 pcsr pwckb pwcka pwm 8 ebr1 eb9/ eb8/ flash 8 h'ff83 syscr2 kwul1 kwul0 p6pue sde cs4e cs3e hi12e hif 8 ebr2 eb7 eb6 eb5 eb4 eb3 eb2 eb1 eb0 flash 8 h'ff84 sbycr ssby sts2 sts1 sts0 sck2 sck1 sck0 system 8 h'ff85 lpwrcr dton lson nesel excle h'ff86 mstpcrh mstp15 mstp14 mstp13 mstp12 mstp11 mstp10 mstp9 mstp8 h'ff87 mstpcrl mstp7 mstp6 mstp5 mstp4 mstp3 mstp2 mstp1 mstp0 h'ff88 smr1 c/ $ chr pe o/ ( stop mp cks1 cks0 sci1 8 iccr1 ice ieic mst trs acke bbsy iric scp iic1 h'ff89 brr1 sci1 8 icsr1 estp stop irtr aasx al aas adz ackb iic1 h'ff8a scr1 tie rie te re mpie teie cke1 cke0 sci1 8 h'ff8b tdr1 h'ff8c ssr1 tdre rdrf orer fer per tend mpb mpbt h'ff8d rdr1
817 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ff8e scmr1 sdir sinv smif sci1 8 icdr1 icdr7 icdr6 icdr5 icdr4 icdr3 icdr2 icdr1 icdr0 iic1 8 sarx1 svax6 svax5 svax4 svax3 svax2 svax1 svax0 fsx h'ff8f icmr1 mls wait cks2 cks1 cks0 bc2 bc1 bc0 sar1 sva6 sva5 sva4 sva3 sva2 sva1 sva0 fs h'ff90 tier iciae icibe icice icide ociae ocibe ovie frt 16 h'ff91 tcsr icfa icfb icfc icfd ocfa ocfb ovf cclra h'ff92 frch h'ff93 frcl h'ff94 ocrah ocrbh h'ff95 ocral ocrbl h'ff96 tcr iedga iedgb iedgc iedgd bufea bufeb cks1 cks0 h'ff97 tocr icrdms ocrams icrs ocrs oea oeb olvla olvlb h'ff98 icrah ocrarh h'ff99 icral ocrarl h'ff9a icrbh ocrafh h'ff9b icrbl ocrafl h'ff9c icrch ocrdmh 0 0 0 0 0 0 0 0 h'ff9d icrcl ocrdml h'ff9e icrdh h'ff9f icrdl h'ffa0 smr2 c/ $ chr pe o/ ( stop mp cks1 cks0 sci2 8 dadrah da13 da12 da11 da10 da9 da8 da7 da6 pwmx dacr test pwme oeb oea os cks h'ffa1 brr2 sci2 8 dadral da5 da4 da3 da2 da1 da0 cfs pwmx
818 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ffa2 scr2 tie rie te re mpie teie cke1 cke0 sci2 8 h'ffa3 tdr2 h'ffa4 ssr2 tdre rdrf orer fer per tend mpb mpbt h'ffa5 rdr2 h'ffa6 scmr2 sdir sinv smif dadrbh da13 da12 da11 da10 da9 da8 da7 da6 pwmx 8 dacnth h'ffa7 dadrbl da5 da4 da3 da2 da1 da0 cfs regs dacntl regs h'ffa8 tcsr0 ovf wt/ ,7 tme rsts rst/ 10, cks2 cks1 cks0 wdt0 16 tcnt0 (write) h'ffa9 tcnt0 (read) h'ffaa paodr pa7odr pa6odr pa5odr pa4odr pa3odr pa2odr pa1odr pa0odr ports 8 h'ffab papin (read) pa7pin pa6pin pa5pin pa4pin pa3pin pa2pin pa1pin pa0pin paddr (write) pa7ddr pa6ddr pa5ddr pa4ddr pa3ddr pa2ddr pa1ddr pa0ddr h'ffac p1pcr p17pcr p16pcr p15pcr p14pcr p13pcr p12pcr p11pcr p10pcr h'ffad p2pcr p27pcr p26pcr p25pcr p24pcr p23pcr p22pcr p21pcr p20pcr h'ffae p3pcr p37pcr p36pcr p35pcr p34pcr p33pcr p32pcr p31pcr p30pcr h'ffb0 p1ddr p17ddr p16ddr p15ddr p14ddr p13ddr p12ddr p11ddr p10ddr h'ffb1 p2ddr p27ddr p26ddr p25ddr p24ddr p23ddr p22ddr p21ddr p20ddr h'ffb2 p1dr p17dr p16dr p15dr p14dr p13dr p12dr p11dr p10dr h'ffb3 p2dr p27dr p26dr p25dr p24dr p23dr p22dr p21dr p20dr h'ffb4 p3ddr p37ddr p36ddr p35ddr p34ddr p33ddr p32ddr p31ddr p30ddr h'ffb5 p4ddr p47ddr p46ddr p45ddr p44ddr p43ddr p42ddr p41ddr p40ddr h'ffb6 p3dr p37dr p36dr p35dr p34dr p33dr p32dr p31dr p30dr h'ffb7 p4dr p47dr p46dr p45dr p44dr p43dr p42dr p41dr p40dr h'ffb8 p5ddr p52ddr p51ddr p50ddr h'ffb9 p6ddr p67ddr p66ddr p65ddr p64ddr p63ddr p62ddr p61ddr p60ddr h'ffba p5dr p52dr p51dr p50dr h'ffbb p6dr p67dr p66dr p65dr p64dr p63dr p62dr p61dr p60dr h'ffbc pbodr pb7odr pb6odr pb5odr pb4odr pb3odr pb2odr pb1odr pb0odr h'ffbd pbpin (read) pb7pin pb6pin pb5pin pb4pin pb3pin pb2pin pb1pin pb0pin p8ddr (write) p86ddr p85ddr p84ddr p83ddr p82ddr p81ddr p80ddr
819 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ffbe p7pin (read) p77pin p76pin p75pin p74pin p73pin p72pin p71pin p70pin ports 8 pbddr (write) pb7ddr pb6ddr pb5ddr pb4ddr pb3ddr pb2ddr pb1ddr pb0ddr h'ffbf p8dr p86dr p85dr p84dr p83dr p82dr p81dr p80dr h'ffc0 p9ddr p97ddr p96ddr p95ddr p94ddr p93ddr p92ddr p91ddr p90ddr h'ffc1 p9dr p97dr p96dr p95dr p94dr p93dr p92dr p91dr p90dr h'ffc2 ier irq7e irq6e irq5e irq4e irq3e irq2e irq1e irq0e interrupt controller 8 h'ffc3 stcr iics iicx1 iicx0 iice flshe icks1 icks0 system 8 h'ffc4 syscr cs2e iose intm1 intm0 xrst nmieg hie rame h'ffc5 mdcr expe mds1 mds0 h'ffc6 bcr icis1 icis0 brstrm brsts1 brsts0 ios1 ios0 bus 8 h'ffc7 wscr rams ram0 abw ast wms1 wms0 wc1 wc0 controller h'ffc8 tcr0 cmieb cmiea ovie cclr1 cclr0 cks2 cks1 cks0 tmr0, 16 h'ffc9 tcr1 cmieb cmiea ovie cclr1 cclr0 cks2 cks1 cks0 tmr1 h'ffca tcsr0 cmfb cmfa ovf adte os3 os2 os1 os0 h'ffcb tcsr1 cmfb cmfa ovf os3 os2 os1 os0 h'ffcc tcora0 h'ffcd tcora1 h'ffce tcorb0 h'ffcf tcorb1 h'ffd0 tcnt0 h'ffd1 tcnt1 h'ffd2 pwoerb oe15 oe14 oe13 oe12 oe11 oe10 oe9 oe8 pwm 8 h'ffd3 pwoera oe7 oe6 oe5 oe4 oe3 oe2 oe1 oe0 h'ffd4 pwdprb os15 os14 os13 os12 os11 os10 os9 os8 h'ffd5 pwdpra os7 os6 os5 os4 os3 os2 os1 os0 h'ffd6 pwsl pwcke pwcks rs3 rs2 rs1 rs0 h'ffd7 pwdr0 to pwdr15 h'ffd8 smr0 c/ $ chr pe o/ ( stop mp cks1 cks0 sci0 8 iccr0 ice ieic mst trs acke bbsy iric scp iic0 h'ffd9 brr0 sci0 icsr0 estp stop irtr aasx al aas adz ackb iic0
820 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ffda scr0 tie rie te re mpie teie cke1 cke0 sci0 8 h'ffdb tdr0 h'ffdc ssr0 tdre rdrf orer fer per tend mpb mpbt h'ffdd rdr0 h'ffde scmr0 sdir sinv smif icdr0 icdr7 icdr6 icdr5 icdr4 icdr3 icdr2 icdr1 icdr0 iic0 sarx0 svax6 svax5 svax4 svax3 svax2 svax1 svax0 fsx h'ffdf icmr0 mls wait cks2 cks1 cks0 bc2 bc1 bc0 sar0 sva6 sva5 sva4 sva3 sva2 sva1 sva0 fs h'ffe0 addrah ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 a/d 8 h'ffe1 addral ad1 ad0 h'ffe2 addrbh ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 h'ffe3 addrbl ad1 ad0 h'ffe4 addrch ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 h'ffe5 addrcl ad1 ad0 h'ffe6 addrdh ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 h'ffe7 addrdl ad1 ad0 h'ffe8 adcsr adf adie adst scan cks ch2 ch1 ch0 h'ffe9 adcr trgs1 trgs0 h'ffea tcsr1 ovf wt/ ,7 tme pss rst/ 10, cks2 cks1 cks0 wdt1 16 tcnt1 (write) h'ffeb tcnt1 (read) h'fff0 hicr ibfie2 ibfie1 fga20e hif 8 tcrx cmieb cmiea ovie cclr1 cclr0 cks2 cks1 cks0 tmrx tcry cmieb cmiea ovie cclr1 cclr0 cks2 cks1 cks0 tmry h'fff1 kmimr kmimr7 kmimr6 kmimr5 kmimr4 kmimr3 kmimr2 kmimr1 kmimr0 interrupt controller 8 tcsrx cmfb cmfa ovf icf os3 os2 os1 os0 tmrx tcsry cmfb cmfa ovf icie os3 os2 os1 os0 tmry h'fff2 kmpcr km7pcr km6pcr km5pcr km4pcr km3pcr km2pcr km1pcr km0pcr ports ticrr tmrx tcoray tmry h'fff3 kmimra kmimr15 kmimr14 kmimr13 kmimr12 kmimr11 kmimr10 kmimr9 kmimr8 interrupt controller 8 ticrf tmrx tcorby tmry
821 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'fff4 idr1 idr7 idr6 idr5 idr4 idr3 idr2 idr1 idr0 hif 8 tcntx tmrx tcnty tmry h'fff5 odr1 odr7 odr6 odr5 odr4 odr3 odr2 odr1 odr0 hif tcorc tmrx tisr is tmry h'fff6 str1 dbu dbu dbu dbu c/ ' dbu ibf obf hif tcorax tmrx h'fff7 tcorbx h'fff8 dadr0 d/a h'fff9 dadr1 h'fffa dacr daoe1 daoe0 dae h'fffc idr2 idr7 idr6 idr5 idr4 idr3 idr2 idr1 idr0 hif tconri simod1 simod0 scone icst hfinv vfinv hiinv viinv timer connection h'fffd odr2 odr7 odr6 odr5 odr4 odr3 odr2 odr1 odr0 hif tconro hoe voe cloe cboe hoinv voinv cloinv cboinv timer connection h'fffe str2 dbu dbu dbu dbu c/ ' dbu ibf obf hif tconrs tmrx/y isgene homod1 homod0 vomod1 vomod0 clmod1 clmod0 timer h'ffff sedgr vedg hedg cedg hfedg vfedg preqf ihi ivi connection
822 b.2 register selection conditions lower address register name h8s/2148 series register selection conditions h8s/2144 series register selection conditions module name h'ec00 mra rame = 1 in syscr dtc to sar h'efff mrb dar cra crb h'fe80 hicr2 mstp2 = 0 hif h'fe84 idr3 h'fe85 odr3 h'fe86 str3 h'fe8c idr4 h'fe8d odr4 h'fe8e str4 h'fed8 kbcrh0 mstp2 = 0 keyboard h'fed9 kbcrl0 buffer h'feda kbbr0 controller h'fedc kbcrh1 h'fedd kbcrl1 h'fede kbbr1 h'fee0 kbcrh2 h'fee1 kbcrl2 h'fee2 kbbr2 h'fee4 kbcomp no conditions no conditions irda/ expansion a/d h'fee6 ddcswr mstp4 = 0 iic0 h'fee8 icra no conditions no conditions interrupt h'fee9 icrb controller h'feea icrc h'feeb isr h'feec iscrh h'feed iscrl h'feee dtcera no conditions dtc h'feef dtcerb h'fef0 dtcerc h'fef1 dtcerd h'fef2 dtcere
823 lower address register name h8s/2148 series register selection conditions h8s/2144 series register selection conditions module name h'fef3 dtvecr no conditions dtc h'fef4 abrkcr no conditions no conditions interrupt h'fef5 bara controller h'fef6 barb h'fef7 barc h'ff80 flmcr1 flshe = 1 in stcr flshe = 1 in stcr flash h'ff81 flmcr2 memory h'ff82 pcsr flshe = 0 in stcr flshe = 0 in stcr pwm ebr1 flshe = 1 in stcr flshe = 1 in stcr flash memory h'ff83 syscr2 flshe = 0 in stcr flshe = 0 in stcr hif ebr2 flshe = 1 in stcr flshe = 1 in stcr flash memory h'ff84 sbycr flshe = 0 in stcr flshe = 0 in stcr system h'ff85 lpwrcr h'ff86 mstpcrh h'ff87 mstpcrl h'ff88 smr1 mstp6 = 0, iice = 0 in stcr mstp6 = 0, iice = 0 in stcr sci1 iccr1 mstp3 = 0, iice = 1 in stcr iic1 h'ff89 brr1 mstp6 = 0, iice = 0 in stcr mstp6 = 0, iice = 0 in stcr sci1 icsr1 mstp3 = 0, iice = 1 in stcr iic1 h'ff8a scr1 mstp6 = 0 mstp6 = 0 sci1 h'ff8b tdr1 h'ff8c ssr1 h'ff8d rdr1 h'ff8e scmr1 mstp6 = 0, iice = 0 in stcr mstp6 = 0, iice = 0 in stcr icdr1 mstp3 = 0, iice = 1 in stcr ice = 1 in iccr1 iic1 sarx1 ice = 0 in iccr1 h'ff8f icmr1 ice = 1 in iccr1 sar1 ice = 0 in iccr1 h'ff90 tier mstp13 = 0 mstp13 = 0 frt h'ff91 tcsr h'ff92 frch h'ff93 frcl h'ff94 ocrah ocrbh
824 lower address register name h8s/2148 series register selection conditions h8s/2144 series register selection conditions module name h'ff95 ocral mstp13 = 0 mstp13 = 0 frt ocrbl h'ff96 tcr h'ff97 tocr h'ff98 icrah ocrarh h'ff99 icral ocrarl h'ff9a icrbh ocrafh h'ff9b icrbl ocrafl h'ff9c icrch ocrdmh h'ff9d icrcl ocrdml h'ff9e icrdh h'ff9f icrdl h'ffa0 smr2 mstp5 = 0, iice = 0 in stcr mstp5 = 0, iice = 0 in stcr sci2 dadrah mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb pwmx dacr regs = 1 in dacnt/ dadrb regs = 1 in dacnt/ dadrb h'ffa1 brr2 mstp5 = 0, iice = 0 in stcr mstp5 = 0, iice = 0 in stcr sci2 dadral mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb pwmx h'ffa2 scr2 mstp5 = 0 mstp5 = 0 sci2 h'ffa3 tdr2 h'ffa4 ssr2 h'ffa5 rdr2 h'ffa6 scmr2 mstp5 = 0, iice = 0 in stcr mstp5 = 0, iice = 0 in stcr dadrbh mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb pwmx dacnth regs = 1 in dacnt/ dadrb regs = 1 in dacnt/ dadrb
825 lower address register name h8s/2148 series register selection conditions h8s/2144 series register selection conditions module name h'ffa7 dadrbl mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb pwmx dacntl regs = 1 in dacnt/ dadrb regs = 1 in dacnt/ dadrb h'ffa8 tcsr0 no conditions no conditions wdt0 tcnt0 (write) h'ffa9 tcnt0 (read) h'ffaa paodr0 no conditions no conditions ports h'ffab papin (read) paddr (write) h'ffac p1pcr h'ffad p2pcr h'ffae p3pcr h'ffb0 p1ddr h'ffb1 p2ddr h'ffb2 p1dr h'ffb3 p2dr h'ffb4 p3ddr h'ffb5 p4ddr h'ffb6 p3dr h'ffb7 p4dr h'ffb8 p5ddr h'ffb9 p6ddr h'ffba p5dr h'ffbb p6dr h'ffbc pbodr h'ffbd p8ddr (write) pbpin (read) h'ffbe p7pin (read) pbddr (write)
826 lower address register name h8s/2148 series register selection conditions h8s/2144 series register selection conditions module name h'ffbf p8dr no conditions no conditions ports h'ffc0 p9ddr h'ffc1 p9dr h'ffc2 ier no conditions no conditions interrupt controller h'ffc3 stcr no conditions no conditions system h'ffc4 syscr h'ffc5 mdcr h'ffc6 bcr bus h'ffc7 wscr controller h'ffc8 tcr0 mstp12 = 0 mstp12 = 0 tmr0, h'ffc9 tcr1 tmr1 h'ffca tcsr0 h'ffcb tcsr1 h'ffcc tcora0 h'ffcd tcora1 h'ffce tcorb0 h'ffcf tcorb1 h'ffd0 tcnt0 h'ffd1 tcnt1 h'ffd2 pwoerb no conditions pwm h'ffd3 pwoera h'ffd4 pwdprb h'ffd5 pwdpra h'ffd6 pwsl mstp11 = 0 h'ffd7 pwdr0 to pwdr15 h'ffd8 smr0 mstp7 = 0, iice = 0 in stcr mstp7 = 0, iice = 0 in stcr sci0 iccr0 mstp4 = 0, iice = 1 in stcr iic0 h'ffd9 brr0 mstp7 = 0, iice = 0 in stcr mstp7 = 0, iice = 0 in stcr sci0 icsr0 mstp4 = 0, iice = 1 in stcr iic0 h'ffda scr0 mstp7 = 0 mstp7 = 0 sci0 h'ffdb tdr0 h'ffdc ssr0 h'ffdd rdr0
827 lower address register name h8s/2148 series register selection conditions h8s/2144 series register selection conditions module name h'ffde scmr0 mstp7 = 0, iice = 0 in stcr mstp7 = 0, iice = 0 in stcr sci0 icdr0 mstp4 = 0, iice = 1 in stcr ice = 1 in iccr0 iic0 sarx0 ice = 0 in iccr0 h'ffdf icmr0 ice = 1 in iccr0 sar0 ice = 0 in iccr0 h'ffe0 addrah mstp9 = 0 mstp9 = 0 a/d h'ffe1 addral h'ffe2 addrbh h'ffe3 addrbl h'ffe4 addrch h'ffe5 addrcl h'ffe6 addrdh h'ffe7 addrdl h'ffe8 adcsr h'ffe9 adcr h'ffea tcsr1 no conditions no conditions wdt1 tcnt1 (write) h'ffeb tcnt1 (read) h'fff0 hicr mstp2 = 0, hie = 1 in syscr hif tcrx mstp8 = 0, hie = 0 in syscr tmrx/y = 0 in tconrs tmrx tcry tmrx/y = 1 in tconrs mstp8 = 0, hie = 0 in syscr tmry h'fff1 kmimr mstp2 = 0, hie = 1 in syscr mstp2 = 0, hie = 1 in syscr interrupt controller tcsrx mstp8 = 0, hie = 0 in syscr tmrx/y = 0 in tconrs tmrx tcsry tmrx/y = 1 in tconrs mstp8 = 0, hie = 0 in syscr tmry h'fff2 kmpcr mstp2 = 0, hie = 1 in syscr mstp2 = 0, hie = 1 in syscr ports ticrr mstp8 = 0, hie = 0 in syscr tmrx/y = 0 in tconrs tmrx tcoray tmrx/y = 1 in tconrs mstp8 = 0, hie = 0 in syscr tmry
828 lower address register name h8s/2148 series register selection conditions h8s/2144 series register selection conditions module name h'fff3 kmimra mstp2 = 0, hie = 1 in syscr mstp2 = 0, hie = 1 in syscr interrupt controller ticrf mstp8 = 0, hie = 0 in syscr tmrx/y = 0 in tconrs tmrx tcorby tmrx/y = 1 in tconrs mstp8 = 0, hie = 0 in syscr tmry h'fff4 idr1 mstp2 = 0, hie = 1 in syscr hif tcntx mstp8 = 0, hie = 0 in syscr tmrx/y = 0 in tconrs tmrx tcnty tmrx/y = 1 in tconrs mstp8 = 0, hie = 0 in syscr tmry h'fff5 odr1 mstp2 = 0, hie = 1 in syscr hif tcorc mstp8 = 0, hie = 0 in syscr tmrx/y = 0 in tconrs tmrx tisr tmrx/y = 1 in tconrs mstp8 = 0, hie = 0 in syscr tmry h'fff6 str1 mstp2 = 0, hie = 1 in syscr hif tcorax mstp8 = 0, hie = 0 in syscr tmrx/y = 0 tmrx h'fff7 tcorbx in tconrs h'fff8 dadr0 mstp10 = 0 mstp10 = 0 d/a h'fff9 dadr1 h'fffa dacr h'fffc idr2 mstp2 = 0, hie = 1 in syscr hif tconri mstp8 = 0, hie = 0 in syscr timer connection h'fffd odr2 mstp2 = 0, hie = 1 in syscr hif tconro mstp8 = 0, hie = 0 in syscr timer connection h'fffe str2 mstp2 = 0, hie = 1 in syscr hif tconrs mstp8 = 0, hie = 0 in syscr timer connection h'ffff sedgr
829 b.3 functions dacr?/a control register h'fffa d/a converter register name address to which the register is mapped name of on-chip supporting module register acronym bit numbers initial bit values names of the bits. dashes (? indicate reserved bits. full name of bit descriptions of bit settings read only write only read and write r w r/w possible types of access bit initial value read/write 7 daoe1 0 r/w 6 daoe0 0 r/w 5 dae 0 r/w 4 ? 1 3 ? 1 0 ? 1 2 ? 1 1 ? 1 d/a enabled daoe1 0 1 conversion result dae * 0 1 0 1 * daoe0 0 1 0 1 channel 0 and 1 d/a conversion disabled channel 0 d/a conversion enabled channel 1 d/a conversion disabled channel 0 and 1 d/a conversion enabled channel 0 d/a conversion disabled channel 1 d/a conversion enabled channel 0 and 1 d/a conversion enabled channel 0 and 1 d/a conversion enabled d/a output enable 0 0 analog output da0 disabled 1 channel 0 d/a conversion enabled. analog output da0 enabled d/a output enable 1 0 analog output da1 disabled 1 channel 1 d/a conversion enabled. analog output da1 enabled
830 mradtc mode register a h'ec00Ch'efff dtc 7 sm1 undefined 6 sm0 undefined 5 dm1 undefined 4 dm0 undefined 3 md1 undefined 0 sz undefined 2 md0 undefined 1 dts undefined bit initial value read/write dtc data transfer size 0 byte-size transfer 1 word-size transfer dtc transfer mode select 0 destination side is repeat area or block area 1 source side is repeat area or block area dtc mode 0 normal mode repeat mode 0 1 1 block transfer mode 0 1 destination address mode 0 dar is fixed dar is incremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 0 1 dar is decremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 1 source address mode 0 sar is fixed sar is incremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 0 1 sar is decremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 1
831 mrbdtc mode register b h'ec00Ch'efff dtc 7 chne undefined 6 disel undefined 5 ? undefined 4 ? undefined 3 ? undefined 0 ? undefined 2 ? undefined 1 ? undefined bit initial value read/write dtc interrupt select 0 after a data transfer ends, the cpu interrupt is disabled unless the transfer counter is 0 1 after a data transfer ends, the cpu interrupt is enabled dtc chain transfer enable 0 end of dtc data transfer 1 dtc chain transfer sardtc source address register h'ec00C h'efff dtc 23 unde- fined bit initial value read/write 22 unde- fined 21 unde- fined 20 unde- fined 19 unde- fined 4 unde- fined 3 unde- fined 2 unde- fined 1 unde- fined 0 unde- fined - - - - - - - - - - - - specifies dtc transfer data source address dardtc destination address register h'ec00Ch'efff dtc 23 unde- fined bit initial value read/write 22 unde- fined 21 unde- fined 20 unde- fined 19 unde- fined 4 unde- fined 3 unde- fined 2 unde- fined 1 unde- fined 0 unde- fined - - - - - - - - - - - - specifies dtc transfer data destination address
832 cradtc transfer count register a h'ec00C h'efff dtc 15 unde- fined bit initial value read/write 14 unde- fined 13 unde- fined 12 unde- fined 11 unde- fined 10 unde- fined 9 unde- fined 8 unde- fined 7 unde- fined 6 unde- fined 5 unde- fined 4 unde- fined 3 unde- fined 2 unde- fined 1 unde- fined 0 unde- fined crah cral specifies the number of dtc data transfers crbdtc transfer count register b h'ec00C h'efff dtc 15 unde- fined bit initial value read/write 14 unde- fined 13 unde- fined 12 unde- fined 11 unde- fined 10 unde- fined 9 unde- fined 8 unde- fined 7 unde- fined 6 unde- fined 5 unde- fined 4 unde- fined 3 unde- fined 2 unde- fined 1 unde- fined 0 unde- fined specifies the number of dtc block data transfers hicr2host interface control register2 h'fe80 hif 7 ? 1 ? ? 6 ? 1 ? ? 5 ? 1 ? ? 4 ? 1 ? ? 3 ? 1 ? ? 0 ? 0 ? ? 2 ibfie4 0 r/w ? 1 ibfie3 0 r/w ? bit initial value slave r/w host r/w input data register full interrupt enable 3 0 input data register (idr3) receive complete interrupt is disabled 1 input data register (idr3) receive complete interrupt is enabled input data register full interrupt enable 4 0 input data register (idr4) receive complete interrupt is disabled 1 input data register (idr4) receive complete interrupt is enabled
833 idr3input data register 3 h'fe84 hif idr4input data register 4 h'fe8c hif 7 idr7 ? r w 6 idr6 ? r w 5 idr5 ? r w 4 idr4 ? r w 3 idr3 ? r w 0 idr0 ? r w 2 idr2 ? r w 1 idr1 ? r w bit initial value slave r/w host r/w stores host data bus contents at rise of iow when cs is low odr3output data register 3 h'fe85 hif odr4output data register 4 h'fe8d hif 7 odr7 ? r/w r 6 odr6 ? r/w r 5 odr5 ? r/w r 4 odr4 ? r/w r 3 odr3 ? r/w r 0 odr0 ? r/w r 2 odr2 ? r/w r 1 odr1 ? r/w r bit initial value slave r/w host r/w odr contents are output to the host data bus when ha0 is low, cs is low, and ior is low
834 str3status register 3 h'fe86 hif str4status register 4 h'fe8e hif 7 dbu 0 r/w r 6 dbu 0 r/w r 5 dbu 0 r/w r 4 dbu 0 r/w r 3 c/ d 0 r r 0 obf 0 r/(w) r 2 dbu 0 r/w r 1 ibf 0 r r bit initial value slave r/w host r/w output buffer full 0 [clearing condition] when the host processor reads odr or the slave writes 0 in the obf bit 1 [setting condition] when the slave processor writes to odr user-defined bits input buffer full 0 [clearing condition] when the slave processor reads idr 1 [setting condition] when the host processor writes to idr command/data 0 contents of input data register (idr) are data 1 contents of input data register (idr) are a command
835 kbcrh0keyboard control register h0 h'fed8 keyboard buffer controller kbcrh1keyboard control register h1 h'fedc keyboard buffer controller kbcrh2keyboard control register h2 h'fee0 keyboard buffer controller kbioe kbf per kbs kclki kdi kbfsel kbie bit initial value read/write 7654321 0 0 1110000 r/w r/(w) * r/(w) * r r r r/w r/w keyboard stop 0 ??stop bit received 1 ??stop bit received note: * only 0 can be written, to clear the flag. parity error 0 [clearing condition] read per when per =1, then write 0 in per 1 [setting condition] when an odd parity error occurs keyboard buffer register full 0 [clearing condition] read kbf when kbf =1, then write 0 in kbf 1 keyboard interrupt enable 0 interrupt requests are disabled 1 interrupt requests are enabled keyboard buffer register full select 0 kbf bit is used as kclk fall interrupt flag 1 kbf bit is used as keyboard buffer full flag keyboard data in 0 kd i/o pin is low 1 kd i/o pin is high keyboard clock in 0 kclk i/o pin is low 1 kclk i/o pin is high keyboard in/out enable 0 the keyboard buffer controller is non-operational (kclk and kd signal pins have port functions) 1 the keyboard buffer controller is enabled for transmission and reception (kclk and kd signal pins are in the bus drive state) [setting conditions] ? when data has been received normally while kbfsel = 1, and has been transferred to kbbr (keyboard buffer register full flag) ? when a kclk falling edge has been detected while kbfsel = 0 (kclk interrupt flag)
836 kbcrl0keyboard control register l0 h'fed9 keyboard buffer controller kbcrl1keyboard control register l1 h'fedd keyboard buffer controller kbcrl2keyboard control register l2 h'fee1 keyboard buffer controller kbe rxcr2 rxcr1 rxcr0 kclko kdo rxcr3 bit initial value read/write 7654321 0 0 1110000 r/w r r r r/w r/w r receive counter rxcr2 rxcr1 0 1 0 1 0 1 0 1 0 1 rxcr0 0 1 0 1 0 1 0 1 0 1 0 1 rxcr3 0 1 receive data contents ? start bit kb0 kb1 kb2 kb3 kb4 kb5 kb6 kb7 parity bit ? ? keyboard data out 0 keyboard buffer controller data i/o pin is low 1 keyboard buffer controller data i/o pin is high keyboard clock out 0 keyboard buffer controller clock i/o pin is low 1 keyboard buffer controller clock i/o pin is high keyboard enable 0 loading of receive data into kbbr is disabled 1 loading of receive data into kbbr is enabled
837 kbbr0keyboard data buffer register 0 h'feda keyboard buffer controller kbbr1keyboard data buffer register 1 h'fede keyboard buffer controller kbbr2keyboard data buffer register 2 h'fee2 keyboard buffer controller kb7 kb2 kb1 kb0 kb6 kb5 kb4 kb3 bit initial value read/write 7654321 0 0 0000000 rrrr rrrr stores receive data
838 kbcompkeyboard comparator control register h'fee4 irda/comp 7 ire 0 r/w 6 ircks2 0 r/w 5 ircks1 0 r/w 4 ircks0 0 r/w 3 kbade 0 r/w 0 kbch0 0 r/w 2 kbch2 0 r/w 1 kbch1 0 r/w bit initial value read/write an6 cin0 cin1 cin2 cin3 cin4 cin5 cin6 cin7 an7 cin8 cin9 cin10 cin11 cin12 cin13 cin14 cin15 keyboard comparator control bit 3 kbade 0 1 a/d converter channel 6 input a/d converter channel 7 input bit 2 kbch2 ? 0 1 bit 1 kbch1 ? 0 1 0 1 bit 0 kbch0 ? 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 b 3/16 (3/16 of the bit rate) ?2 ?4 ?8 ?16 ?32 ?64 ?128 irda clock select 2 to 0 irda enable 0 the txd2/irtxd and rxd2/irrxd pins function as txd2 and rxd2 1 the txd2/irtxd and rxd2/irrxd pins function as irtxd and irrxd
839 ddcswrddc switch register h'fee6 iic0 7 swe 0 r/w 6 sw 0 r/w 5 ie 0 r/w 4 if 0 r/(w) * 1 3 clr3 1 w * 2 0 clr0 1 w * 2 2 clr2 1 w * 2 1 clr1 1 w * 2 bit initial value read/write ddc mode switch interrupt flag 0 no interrupt is requested when automatic format switching is executed [clearing condition] when 0 is written in if after reading if = 1 1 an interrupt is requested when automatic format switching is executed [setting condition] when a falling edge is detected on the scl pin when swe = 1 ddc mode switch interrupt enable bit 0 interrupt when automatic format switching is executed is disabled 1 interrupt when automatic format switching is executed is enabled ddc mode switch 0 iic channel 0 is used with the i 2 c bus format [clearing conditions] ? when 0 is written by software ? when a falling edge is detected on the scl pin when swe = 1 1 iic channel 0 is used in formatless mode [setting condition] when 1 is written in sw after reading sw = 0 ddc mode switch enable 0 automatic switching of iic channel 0 from formatless mode to i 2 c bus format is disabled 1 automatic switching of iic channel 0 from formatless mode to i 2 c bus format is enabled iic clear bits bit 3 clr3 0 1 description setting prohibited setting prohibited iic0 internal latch cleared iic1 internal latch cleared iic0 and iic1 internal latches cleared invalid setting bit 2 clr2 0 1 ? bit 1 clr1 ? 0 1 ? bit 0 clr0 ? 0 1 0 1 ? notes: 1. only 0 can be written, to clear the flag. 2. always read as 1.
840 icrainterrupt control register a h'fee8 interrupt controller icrbinterrupt control register b h'fee9 interrupt controller icrcinterrupt control register c h'feea interrupt controller 7 icr7 0 r/w 6 icr6 0 r/w 5 icr5 0 r/w 4 icr4 0 r/w 3 icr3 0 r/w 0 icr0 0 r/w 2 icr2 0 r/w 1 icr1 0 r/w bit initial value read/write interrupt control level 0 corresponding interrupt source is control level 0 (non-priority) 1 corresponding interrupt source is control level 1 (priority) correspondence between interrupt sources and icr settings register bits 76543210 icra irq0 irq1 irq2 irq3 irq4 irq5 irq6 irq7 dtc watchdog timer 0 watchdog timer 1 icrb a/d converter free- running timer ? 8-bit timer channel 0 8-bit timer channel 1 8-bit timer channels x, y hif, keyboard buffer controller icrc sci channel 0 sci channel 1 sci channel 2 iic channel 0 (option) iic channel 1 (option)
841 isrirq status register h'feeb interrupt controller 7 irq7f 0 r/(w) * 6 irq6f 0 r/(w) * 5 irq5f 0 r/(w) * 4 irq4f 0 r/(w) * 3 irq3f 0 r/(w) * 0 irq0f 0 r/(w) * 2 irq2f 0 r/(w) * 1 irq1f 0 r/(w) * bit initial value read/write irq7 to irq0 flags 0 [clearing conditions] ? cleared by reading irqnf when set to 1, then writing 0 in irqnf ? when interrupt exception handling is executed while low-level detection is set (irqnscb = irqnsca = 0) and irqn input is high ? when irqn interrupt exception handling is executed while falling, rising, or both-edge detection is set (irqnscb = 1 or irqnsca = 1) 1 [setting conditions] ? when irqn input goes low when low-level detection is set (irqnscb = irqnsca = 0) ? when a falling edge occurs in irqn input while falling edge detection is set (irqnscb = 0, irqnsca = 1) ? when a rising edge occurs in irqn input while rising edge detection is set (irqnscb = 1, irqnsca = 0) ? when a falling or rising edge occurs in irqn input while both-edge detection is set (irqnscb = irqnsca = 1) note: * only 0 can be written, to clear the flag. (n = 7 to 0)
842 iscrhirq sense control register h h'feec interrupt controller iscrlirq sense control register l h'feed interrupt controller 15 irq7scb 0 r/w 14 irq7sca 0 r/w 13 irq6scb 0 r/w 12 irq6sca 0 r/w 11 irq5scb 0 r/w 8 irq4sca 0 r/w 10 irq5sca 0 r/w 9 irq4scb 0 r/w bit initial value read/write iscrh 7 irq3scb 0 r/w 6 irq3sca 0 r/w 5 irq2scb 0 r/w 4 irq2sca 0 r/w 3 irq1scb 0 r/w 0 irq0sca 0 r/w 2 irq1sca 0 r/w 1 irq0scb 0 r/w bit initial value read/write iscrl irq7 to irq4 sense control a and b irq3 to irq0 sense control a and b description iscrh bits 7 to 0 iscrl bits 7 to 0 irq7scb to irq0scb irq7sca to irq0sca 0 1 0 1 0 1 interrupt request generated at irq7 to irq0 input at low level interrupt request generated at falling edge of irq7 to irq0 input interrupt request generated at rising edge of irq7 to irq0 input interrupt request generated at both falling and rising edges of irq7 to irq0 input
843 dtcerdtc enable register h'feee to h'fef2 dtc 7 dtce7 0 r/w 6 dtce6 0 r/w 5 dtce5 0 r/w 4 dtce4 0 r/w 3 dtce3 0 r/w 0 dtce0 0 r/w 2 dtce2 0 r/w 1 dtce1 0 r/w bit initial value read/write dtc activation enable 0 dtc activation by interrupt is disabled [clearing conditions] ? when data transfer ends with the disel bit set to 1 ? when the specified number of transfers end 1 dtc activation by interrupt is enabled [holding condition] when the disel bit is 0 and the specified number of transfers have not ended dtvecrdtc vector register h'fef3 dtc 7 swdte 0 r/(w) * 6 dtvec6 0 r/w 5 dtvec5 0 r/w 4 dtvec4 0 r/w 3 dtvec3 0 r/w 0 dtvec0 0 r/w 2 dtvec2 0 r/w 1 dtvec1 0 r/w bit initial value read/write note: * sets vector number for dtc software activation dtc software activation enable 0 dtc software activation is disabled [clearing condition] when the disel bit is 0 and the specified number of transfers have not ended 1 dtc software activation is enabled [holding conditions] ? when data transfer ends with the disel bit set to 1 ? when the specified number of transfers end ? during software-activated deta transfer a value of 1 can always be written to the swdte bit, but 0 can only be written after 1 is read.
844 abrkcraddress break control register h'fef4 interrupt controller 7 cmf 0 r/w 6 ? 0 5 ? 0 4 ? 0 3 ? 0 0 bie 0 r/w 2 ? 0 1 ? 0 bit initial value read/write break interrupt enable 0 address break disabled 1 address break enabled condition match flag 0 [clearing condition] when address break interrupt exception handling is executed 1 [setting condition] when address set by bara to barc is prefetched while bie = 1
845 barabreak address register a h'fef5 interrupt controller barbbreak address register b h'fef6 interrupt controller barcbreak address register c h'fef7 interrupt controller 7 a23 0 r/w 6 a22 0 r/w 5 a21 0 r/w 4 a20 0 r/w 3 a19 0 r/w 0 a16 0 r/w 2 a18 0 r/w 1 a17 0 r/w bit bara initial value read/write 7 a15 0 r/w 6 a14 0 r/w 5 a13 0 r/w 4 a12 0 r/w 3 a11 0 r/w 0 a8 0 r/w 2 a10 0 r/w 1 a9 0 r/w bit barb initial value read/write 7 a7 0 r/w 6 a6 0 r/w 5 a5 0 r/w 4 a4 0 r/w 3 a3 0 r/w 0 ? 0 2 a2 0 r/w 1 a1 0 r/w bit barc initial value read/write specifies address (bits 23 to 16) at which address break is to be generated specifies address (bits 15 to 8) at which address break is to be generated specifies address (bits 7 to 1) at which address break is to be generated
846 flmcr1flash memory control register 1 h'ff80 flash memory 7 fwe ? r 6 swe 0 r/w 5 ? 0 4 ? 0 3 ev 0 r/w 0 p 0 r/w 2 pv 0 r/w 1 e 0 r/w bit initial value read/write program 0 program mode cleared 1 transition to program mode [setting condition] when swe = 1, and psu = 1 erase 0 erase mode cleared 1 transition to erase mode [setting condition] when swe = 1, and esu = 1 program-verify 0 program-verify mode cleared 1 transition to program-verify mode [setting condition] when swe = 1 erase-verify 0 erase-verify mode cleared 1 transition to erase-verify mode [setting condition] when swe = 1 software write enable 0 writes disabled 1 writes enabled reserved bit
847 flmcr2flash memory control register 2 h'ff81 flash memory 7 fler 0 r 6 ? 0 5 ? 0 4 ? 0 3 ? 0 0 psu 0 r/w 2 ? 0 1 esu 0 r/w bit initial value read/write program setup 0 program setup cleared 1 program setup [setting condition] when swe = 1 erase setup 0 erase setup cleared 1 erase setup [setting condition] when swe = 1 flash memory error 0 flash memory is operating normally flash memory program/erase protection (error protection) is disabled [clearing condition] reset or hardware standby mode 1 an error has occurred during flash memory programming/erasing flash memory program/erase protection (error protection) is enabled [setting condition] see section 22.8.3, error protection
848 pcsrperipheral clock select register h'ff82 pwm 7 ? 0 6 ? 0 5 ? 0 4 ? 0 3 ? 0 0 ? 0 2 pwckb 0 r/w 1 pwcka 0 r/w bit initial value read/write pwm clock select pwsl pcsr bit 7 pwcke 0 1 bit 6 pwcks ? 0 1 bit 2 pwckb ? ? 0 1 bit 1 pwcka ? ? 0 1 0 1 clock input is disabled ?(system clock) is selected ?2 is selected ?4 is selected ?8 is selected ?16 is selected description
849 syscr2system control register 2 h'ff83 hif 7 kwul1 0 r/w 6 kwul0 0 r/w 5 p6pue 0 r/w 4 ? 0 3 sde 0 r/w 0 hi12e 0 r/w 2 cs4e 0 r/w 1 cs3e 0 r/w bit initial value read/write host interface enable 0 host interface functions are disabled 1 host interface functions are enabled shutdown enable 0 host interface pin shutdown function disabled 1 host interface pin shutdown function enabled cs4 enable 0 host interface pin channel 4 functions disabled 1 host interface pin channel 4 functions enabled cs3 enable 0 host interface pin channel 3 functions disabled 1 host interface pin channel 3 functions enabled port 6 input pull-up extra 0 standard current specification is selected for port 6 mos input pull-up function 1 current-limit specification is selected for port 6 mos input pull-up function key wakeup level 1 and 0 0 standard input level is selected as port 6 input level input level 1 is selected as port 6 input level input level 2 is selected as port 6 input level input level 3 is selected as port 6 input level 0 1 10 1
850 ebr1erase block register 1 h'ff82 flash memory ebr2erase block register 2 h'ff83 flash memory 7 ? 0 6 ? 0 5 ? 0 4 ? 0 3 ? 0 0 eb8/ * 2 0 r/w * 1, * 2 2 ? 0 1 eb9/ * 2 0 r/w * 1, * 2 bit initial value read/write 7 eb7 0 r/w * 1 6 eb6 0 r/w 5 eb5 0 r/w 4 eb4 0 r/w 3 eb3 0 r/w 0 eb0 0 r/w 2 eb2 0 r/w 1 eb1 0 r/w bit initial value read/write block (size) 128-kbyte versions 64-kbyte versions erase blocks eb0 (1 kbyte) eb1 (1 kbyte) eb2 (1 kbyte) eb3 (1 kbyte) eb4 (28 kbytes) eb5 (16 kbytes) eb6 (8 kbytes) eb7 (8 kbytes) eb8 (32 kbytes) eb9 (32 kbytes) eb0 (1 kbyte) eb1 (1 kbyte) eb2 (1 kbyte) eb3 (1 kbyte) eb4 (28 kbytes) eb5 (16 kbytes) eb6 (8 kbytes) eb7 (8 kbytes) ? addresses h'(00)0000 to h'(00)03ff h'(00)0400 to h'(00)07ff h'(00)0800 to h'(00)0bff h'(00)0c00 to h'(00)0fff h'(00)1000 to h'(00)7fff h'(00)8000 to h'(00)bfff h'(00)c000 to h'(00)dfff h'00e000 to h'00ffff h'010000 to h'017fff h'018000 to h'01ffff notes: 1. in normal mode, these bits cannot be modified and are always read as 0. 2. bits eb8 and eb9 are not present in the 64-kbyte versions; they cannot be modified and are always read as 0.
851 sbycrstandby control register h'ff84 system 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 ? 0 0 sck0 0 r/w 2 sck2 0 r/w 1 sck1 0 r/w bit initial value read/write 0 1 0 1 0 1 0 1 0 1 bus master is in high-speed mode medium-speed clock = ?2 medium-speed clock = ?4 medium-speed clock = ?8 medium-speed clock = ?16 medium-speed clock = ?32 ? 0 1 system clock select 2 to 0 0 1 0 1 0 1 0 1 0 1 0 1 standby time = 8192 states standby time = 16384 states standby time = 32768 states standby time = 65536 states standby time = 131072 states standby time = 262144 states reserved standby time = 16 states * 0 1 standby timer select 2 to 0 software standby 0 transition to sleep mode after execution of sleep instruction in high-speed mode or medium-speed mode transition to subsleep mode on execution of sleep instruction in subactive mode 1 transition to software standby mode, subactive mode, or watch mode after execution of sleep instruction in high-speed mode or medium-speed mode transition to watch mode or high-speed mode after execution of sleep instruction in subactive mode note: * this setting must not be used in the flash memory version.
852 lpwrcrlow-power control register h'ff85 system 7 dton 0 r/w 6 lson 0 r/w 5 nesel 0 r/w 4 excle 0 r/w 3 ? 0 0 ? 0 2 ? 0 1 ? 0 bit initial value read/write subclock input enable 0 subclock input from excl pin is disabled 1 subclock input from excl pin is enabled noise elimination sampling frequency select 0 sampling at ?divided by 32 1 sampling at ?divided by 4 low-speed on flag 0 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, software standby mode, or watch mode * ? when a sleep instruction is executed in subactive mode, a transition is made to watch mode, or directly to high-speed mode ? after watch mode is cleared, a transition is made to high-speed mode 1 when a sleep instruction is executed in high-speed mode a transition is made to watch mode or subactive mode * ? when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode or watch mode ? after watch mode is cleared, a transition is made to subactive mode direct-transfer on flag 0 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, software standby mode, or watch mode * ? when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode or watch mode 1 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made directly to subactive mode * , or a transition is made to sleep mode or software standby mode ? when a sleep instruction is executed in subactive mode, a transition is made directly to high-speed mode, or a transition is made to subsleep mode note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set. note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set.
853 mstpcrhmodule stop control register h h'ff86 system mstpcrlmodule stop control register l h'ff87 system 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl module stop 0 module stop mode is cleared 1 module stop mode is set mstp15 mstp14 * mstp13 mstp12 mstp11 mstp10 mstp9 mstp8 mstp7 mstp6 mstp5 mstp4 * mstp3 * mstp2 * mstp1 * mstp0 * ? data transfer controller (dtc) 16-bit free-running timer (frt) 8-bit timers (tmr0, tmr1) 8-bit pwm timer (pwm), 14-bit pwm timer (pwmx) d/a converter a/d converter 8-bit timers (tmrx, tmry), timer connection serial communication interface 0 (sci0) serial communication interface 1 (sci1) serial communication interface 2 (sci2) i 2 c bus interface (iic) channel 0 (option) i 2 c bus interface (iic) channel 1 (option) host interface (hif), keyboard buffer controller (ps2) ? ? mstpcrh mstpcrl register bit module the correspondence between mstpcr bits and on-chip supporting modules is shown below. notes: bits 1 and 0 can be read and written but do not affect operation. * must be set to 1 in the h8s/2144 series.
854 smr1serial mode register 1 h'ff88 sci1 smr2serial mode register 2 h'ffa0 sci2 smr0serial mode register 0 h'ffd8 sci0 7 c/ a 0 r/w 6 chr 0 r/w 5 pe 0 r/w 4 o/ e 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w bit initial value read/write clock select 1 and 0 0 clock ?4 clock ?16 clock ?64 clock 0 1 10 1 stop bit length 0 1 stop bit 2 stop bits 1 multiprocessor mode 0 multiprocessor function disabled 1 multiprocessor format selected parity mode 0 even parity odd parity 1 parity enable 0 parity bit addition and checking disabled parity bit addition and checking enabled 1 character length 0 8-bit data 7-bit data * 1 note: * when 7-bit data is selected, the msb (bit 7) of tdr is not transmitted. also, lsb-first/ msb-first selection is not available. communication mode 0 asynchronous mode synchronous mode 1
855 iccr1i 2 c bus control register 1 h'ff88 iic1 iccr0i 2 c bus control register 0 h'ffd8 iic0 7 ice 0 r/w 6 ieic 0 r/w 5 mst 0 r/w 4 trs 0 r/w 3 acke 0 r/w 0 scp 1 w 2 bbsy 0 r/w 1 iric 0 r/(w) * bit initial value read/write start condition/stop condition prohibit 0 writing 0 issues a start or stop condition, in combination with the bbsy flag 1 reading always returns a value of 1; writing is ignored i 2 c bus interface interrupt request flag 0 waiting for transfer, or transfer in progress 1 interrupt requested note: for the clearing and setting conditions, see section 16.2.5, i 2 c bus control register (iccr). bus busy 0 bus is free [clearing condition] when a stop condition is detected 1 bus is busy [setting condition] when a start condition is detected acknowledge bit judgement selection 0 the value of the acknowledge bit is ignored, and continuous transfer is performed 1 if the acknowledge bit is 1, continuous transfer is interrupted master/slave select (mst), transmit/receive select (trs) 0 slave receive mode slave transmit mode master receive mode master transmit mode 0 1 10 1 i 2 c bus interface interrupt enable 0 interrupts disabled 1 interrupts enabled note: for details, see section 16.2.5, i 2 c bus control register (iccr). i 2 c bus interface enable 0 i 2 c bus interface module disabled, with scl and sda signal pins set to port function sar and sarx can be accessed 1i 2 c bus interface module enabled for transfer operations (pins scl and sca are driving the bus) icmr and icdr can be accessed note: * only 0 can be written, to clear the flag.
856 brr1bit rate register 1 h'ff89 sci1 brr2bit rate register 2 h'ffa1 sci2 brr0bit rate register 0 h'ffd9 sci0 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write sets the serial transmit/receive bit rate
857 icsr1i 2 c bus status register 1 h'ff89 iic1 icsr0i 2 c bus status register 0 h'ffd9 iic0 7 estp 0 r/(w) * 1 6 stop 0 r/(w) * 1 5 irtr 0 r/(w) * 1 4 aasx 0 r/(w) * 1 3 al 0 r/(w) * 1 0 ackb 0 r/w 2 aas 0 r/(w) * 1 1 adz 0 r/(w) * 1 bit initial value read/write acknowledge bit 0 receive mode: 0 is output at acknowledge output timing transmit mode: indicates that the receiving device has acknowledged the data (signal is 0) 1 receive mode: 1 is output at acknowledge output timing transmit mode: indicates that the receiving device has not acknowledged the data (signal is 1) notes: general call address recognition flag * 2 0 general call address not recognized 1 general call address recognized slave address recognition flag * 2 0 slave address or general call address not recognized 1 slave address or general call address recognized arbitration lost * 2 0 bus arbitration won 1 arbitration lost second slave address recognition flag * 2 0 second slave address not recognized 1 second slave address recognized i 2 c bus interface continuous transmission/reception interrupt request flag * 2 0 waiting for transfer, or transfer in progress 1 continuous transfer state normal stop condition detection flag * 2 0 no normal stop condition 1 in i 2 c bus format slave mode: normal stop condition detected in other modes: no meaning error stop condition detection flag * 2 0 no error stop condition 1 in i 2 c bus format slave mode: error stop condition detected in other modes: no meaning 1. only 0 can be written, to clear the flag. 2. for the clearing and setting conditions, see section 16.2.6, i 2 c bus status register (icsr).
858 scr1serial control register 1 h'ff8a sci1 scr2serial control register 2 h'ffa2 sci2 scr0serial control register 0 h'ffda sci0 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w bit initial value read/write clock enable 1 and 0 0 asynchronous mode synchronous mode 0 asynchronous mode 1 synchronous mode 1 asynchronous mode 0 synchronous mode asynchronous mode 1 synchronous mode internal clock/sck pin functions as i/o port internal clock/sck pin functions as serial clock output internal clock/sck pin functions as clock output internal clock/sck pin functions as serial clock output external clock/sck pin functions as clock input external clock/sck pin functions as serial clock input external clock/sck pin functions as clock input external clock/sck pin functions as serial clock input transmit end interrupt enable 0 transmit-end interrupt (tei) request disabled 1 transmit-end interrupt (tei) request enabled multiprocessor interrupt enable 0 multiprocessor interrupts disabled (normal reception mode) [clearing conditions] ? when the mpie bit is cleared to 0 ? when data with mpb = 1 is received 1 multiprocessor interrupts enabled receive interrupt (rxi) requests, receive-error interrupt (eri) requests, and setting of the rdrf, fer, and orer flags in ssr are disabled until data with the multiprocessor bit set to 1 is received receive enable 0 reception disabled 1 reception enabled transmit enable 0 transmission disabled 1 transmission enabled receive interrupt enable 0 receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request disabled 1 receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request enabled transmit interrupt enable 0 transmit-data-empty interrupt (txi) request disabled 1 transmit-data-empty interrupt (txi) request enabled
859 rdr1receive data register 1 h'ff8d sci1 rdr2receive data register 2 h'ffa5 sci2 rdr0receive data register 0 h'ffdd sci0 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r bit initial value read/write stores serial receive data tdr1transmit data register 1 h'ff8b sci1 tdr2transmit data register 2 h'ffa3 sci2 tdr0transmit data register 0 h'ffdb sci0 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write stores serial transmit data
860 ssr1serial status register 1 h'ff8c sci1 ssr2serial status register 2 h'ffa4 sci2 ssr0serial status register 0 h'ffdc sci0 7 tdre 1 r/(w) * 6 rdrf 0 r/(w) * 5 orer 0 r/(w) * 4 fer 0 r/(w) * 3 per 0 r/(w) * 0 mpbt 0 r/w 2 tend 1 r 1 mpb 0 r bit initial value read/write multiprocessor bit transfer 0 data with a 0 multi-processor bit is transmitted 1 data with a 1 multi-processor bit is transmitted note: * only 0 can be written, to clear the flag. multiprocessor bit 0 [clearing condition] when data with a 0 multiprocessor bit is received 1 [setting condition] when data with a 1 multiprocessor bit is received transmit end 0 [clearing conditions] ? when 0 is written in tdre after reading tdre = 1 ? when the dtc is activated by a txi interrupt and writes data to tdr 1 [setting conditions] ? when the te bit in scr is 0 ? when tdre = 1 at transmission of the last bit of a 1-byte serial transmit character parity error 0 [clearing condition] when 0 is written in per after reading per = 1 1 [setting condition] when, in reception, the number of 1 bits in the receive data plus the parity bit does not match the parity setting (even or odd) specified by the o/ e bit in smr framing error 0 [clearing condition] when 0 is written in fer after reading fer = 1 1 [setting condition] when the sci checks the stop bit at the end of the receive data when reception ends, and the stop bit is 0 overrun error 0 [clearing condition] when 0 is written in orer after reading orer = 1 1 [setting condition] when the next serial reception is completed while rdrf = 1 receive data register full 0 [clearing conditions] ? when 0 is written in rdrf after reading rdrf = 1 ? when the dtc is activated by an rxi interrupt and reads data from rdr 1 [setting condition] when serial reception ends normally and receive data is transferred from rsr to rdr transmit data register empty 0 [clearing conditions] ? when 0 is written in tdre after reading tdre = 1 ? when the dtc is activated by a txi interrupt and writes data to tdr 1 [setting conditions] ? when the te bit in scr is 0 ? when data is transferred from tdr to tsr and data can be written in tdr
861 scmr1serial interface mode register 1 h'ff8e sci1 scmr2serial interface mode register 2 h'ffa6 sci2 scmr0serial interface mode register 0 h'ffde sci0 7 ? 1 6 ? 1 5 ? 1 4 ? 1 3 sdir 0 r/w 0 smif 0 r/w 2 sinv 0 r/w 1 ? 1 bit initial value read/write serial communication interface mode select 0 normal sci mode 1 setting prohibited data invert 0 tdr contents are transmitted without modification receive data is stored in rdr without modification 1 tdr contents are inverted before being transmitted receive data is stored in rdr in inverted form data transfer direction 0 tdr contents are transmitted lsb-first receive data is stored in rdr lsb-first 1 tdr contents are transmitted msb-first receive data is stored in rdr msb-first
862 icdr1i 2 c bus data register 1 h'ff8e iic1 icdr0i 2 c bus data register 0 h'ffde iic0 7 icdr7 ? r/w 6 icdr6 ? r/w 5 icdr5 ? r/w 4 icdr4 ? r/w 3 icdr3 ? r/w 0 icdr0 ? r/w 2 icdr2 ? r/w 1 icdr1 ? r/w bit initial value read/write 7 icdrr7 ? r 6 icdrr6 ? r 5 icdrr5 ? r 4 icdrr4 ? r 3 icdrr3 ? r 0 icdrr0 ? r 2 icdrr2 ? r 1 icdrr1 ? r bit initial value read/write icdrr icdrs 7 icdrs7 ? 6 icdrs6 ? 5 icdrs5 ? 4 icdrs4 ? 3 icdrs3 ? 0 icdrs0 ? 2 icdrs2 ? 1 icdrs1 ? bit initial value read/write icdrt 7 icdrt7 ? w 6 icdrt6 ? w 5 icdrt5 ? w 4 icdrt4 ? w 3 icdrt3 ? w 0 icdrt0 ? w 2 icdrt2 ? w 1 icdrt1 ? w bit initial value read/write tdre, rdrf (internal flags) ? rdrf 0 ? tdre 0 bit initial value read/write note: for details, see section 16.2.1, i 2 c bus data register (icdr).
863 sarx1second slave address register 1 h'ff8e iic1 sar1slave address register 1 h'ff8f iic1 sarx0second slave address register 0 h'ffde iic0 sar0slave address register 0 h'ffdf iic0 7 sva6 0 r/w 6 sva5 0 r/w 5 sva4 0 r/w 4 sva3 0 r/w 3 sva2 0 r/w 0 fs 0 r/w 2 sva1 0 r/w 1 sva0 0 r/w bit initial value read/write sar sarx slave address format select second slave address 7 svax6 0 r/w 6 svax5 0 r/w 5 svax4 0 r/w 4 svax3 0 r/w 3 svax2 0 r/w 0 fsx 1 r/w 2 svax1 0 r/w 1 svax0 0 r/w bit initial value read/write note: * format select ddcswr bit 6 sw sar bit 0 fs sarx bit 0 fsx operating mode i 2 c bus format ? sar and sarx slave addresses recognized 0 00 i 2 c bus format ? sar slave address recognized ? sarx slave address ignored i 2 c bus format ? sar slave address ignored ? sarx slave address recognized synchronous serial format ? sar and sarx slave addresses ignored formatless mode (start/stop conditions not detected) ? acknowledge bit used formatless mode * (start/stop conditions not detected) ?no acknowledge bit 1 10 1 100 1 10 1 do not set this mode when automatic switching to the i 2 c bus format is performed by means of the ddcswr setting.
864 icmr1i 2 c bus mode register 1 h'ff8f iic1 icmr0i 2 c bus mode register 0 h'ffdf iic0 7 mls 0 r/w 6 wait 0 r/w 5 cks2 0 r/w 4 cks1 0 r/w 3 cks0 0 r/w 0 bc0 0 r/w 2 bc2 0 r/w 1 bc1 0 r/w bit initial value read/write bit counter bc2 bc1 0 1 0 1 0 1 bc0 0 1 0 1 0 1 0 1 note: * do not set this bit to 1 when the i 2 c bus format is used. synchronous serial format 8 1 2 3 4 5 6 7 i 2 c bus format 9 2 3 4 5 6 7 8 serial clock select cks2 cks1 0 1 0 1 0 1 0 1 0 1 0 1 cks0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 iicx 0 1 clock ?28 ?40 ?48 ?64 ?80 ?100 ?112 ?128 ?56 ?80 ?96 ?128 ?160 ?200 ?224 ?256 wait insertion bit 0 data and acknowledge bits transferred consecutively 1 wait inserted between data and acknowledge bits msb-first/lsb-first select * 0 msb-first 1 lsb-first
865 tiertimer interrupt enable register h'ff90 frt 7 iciae 0 r/w 6 icibe 0 r/w 5 icice 0 r/w 4 icide 0 r/w 3 ociae 0 r/w 0 ? 1 2 ocibe 0 r/w 1 ovie 0 r/w bit initial value read/write input capture interrupt a enable 0 input capture interrupt request a (icia) is disabled 1 input capture interrupt request a (icia) is enabled input capture interrupt b enable 0 input capture interrupt request b (icib) is disabled 1 input capture interrupt request b (icib) is enabled input capture interrupt c enable 0 input capture interrupt request c (icic) is disabled 1 input capture interrupt request c (icic) is enabled input capture interrupt d enable 0 input capture interrupt request d (icid) is disabled 1 input capture interrupt request d (icid) is enabled output compare interrupt a enable 0 output compare interrupt request a (ocia) is disabled 1 output compare interrupt request a (ocia) is enabled output compare interrupt b enable 0 output compare interrupt request b (ocib) is disabled 1 output compare interrupt request b (ocib) is enabled timer overflow interrupt enable 0 timer overflow interrupt request (fovi) is disabled 1 timer overflow interrupt request (fovi) is enabled
866 tcsrtimer control/status register h'ff91 frt 7 icfa 0 r/(w) * 6 icfb 0 r/(w) * 5 icfc 0 r/(w) * 4 icfd 0 r/(w) * 3 ocfa 0 r/(w) * 0 cclra 0 r/w 2 ocfb 0 r/(w) * 1 ovf 0 r/(w) * bit initial value read/write input capture flag a note: * only 0 can be written in bits 7 to 1, to clear the flags. 0 [clearing condition] read icfa when icfa = 1, then write 0 in icfa 1 [setting condition] when an input capture signal causes the frc value to be transferred to icra input capture flag b 0 [clearing condition] read icfb when icfb = 1, then write 0 in icfb 1 [setting condition] when an input capture signal causes the frc value to be transferred to icrb input capture flag c 0 [clearing condition] read icfc when icfc = 1, then write 0 in icfc 1 [setting condition] when an input capture signal is received input capture flag d 0 [clearing condition] read icfd when icfd = 1, then write 0 in icfd 1 [setting condition] when an input capture signal is received counter clear a 0 frc clearing is disabled 1 frc is cleared at compare match a timer overflow flag 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] when frc changes from h'ffff to h'0000 output compare flag b 0 [clearing condition] read ocfb when ocfb = 1, then write 0 in ocfb 1 [setting condition] when frc = ocrb output compare flag a 0 [clearing condition] read ocfa when ocfa = 1, then write 0 in ocfa 1 [setting condition] when frc = ocra
867 frcfree-running counter h'ff92 frt 15 0 r/w 14 0 r/w 13 0 r/w 12 0 r/w 11 0 r/w 8 0 r/w 10 0 r/w 9 0 r/w bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w count value ocra/ocrboutput compare register a/b h'ff94 frt 15 1 r/w 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 8 1 r/w 10 1 r/w 9 1 r/w bit initial value read/write 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w constantly compared with frc value; ocf is set when ocr = frc
868 tcrtimer control register h'ff96 frt 7 iedga 0 r/w 6 iedgb 0 r/w 5 iedgc 0 r/w 4 iedgd 0 r/w 3 bufea 0 r/w 0 cks0 0 r/w 2 bufeb 0 r/w 1 cks1 0 r/w bit initial value read/write input edge select a 0 capture on the falling edge of ftia capture on the rising edge of ftia 1 input edge select b 0 capture on the falling edge of ftib capture on the rising edge of ftib 1 input edge select c 0 capture on the falling edge of ftic capture on the rising edge of ftic 1 input edge select d 0 capture on the falling edge of ftid capture on the rising edge of ftid 1 buffer enable a 0 icrc is not used as a buffer register for input capture a icrc is used as a buffer register for input capture a 1 buffer enable b 0 icrd is not used as a buffer register for input capture b 1 clock select 0 ?2 internal clock source 0 1 ?8 internal clock source ?32 internal clock source external clock source (rising edge) 0 1 1 icrd is used as a buffer register for input capture b
869 tocrtimer output compare control register h'ff97 frt 7 icrdms 0 r/w 6 ocrams 0 r/w 5 icrs 0 r/w 4 ocrs 0 r/w 3 oea 0 r/w 0 olvlb 0 r/w 2 oeb 0 r/w 1 olvla 0 r/w bit initial value read/write output level b 0 0 output at compare- match b 1 1 output at compare- match b output level a 0 0 output at compare- match a 1 1 output at compare- match a output enable b 0 output compare b output disabled 1 output compare b output enabled output enable a 0 output compare a output disabled 1 output compare a output enabled output compare register select 0 ocra register selected 1 ocrb register selected input capture register select 0 icra, icrb, and icrc registers selected 1 ocrar, ocraf, and ocrdm registers selected output compare a mode select 0 ocra set to normal operating mode 1 ocra set to operating mode using ocrar and ocraf input capture d mode select 0 icrd set to normal operating mode 1 icrd set to operating mode using ocrdm
870 ocraroutput compare register ar h'ff98 frt ocrafoutput compare register af h'ff9a frt 15 1 r/w 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 8 1 r/w 10 1 r/w 9 1 r/w bit initial value read/write 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w used for ocra operation when ocrams = 1 in tocr (for details, see section 11.2.4, output compare registers ar and af (ocrar, ocraf).) ocrdmoutput compare register dm h'ff9c frt 15 0 r 14 0 r 13 0 r 12 0 r 11 0 r 8 0 r 10 0 r 9 0 r bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w used for icrd operation when icrdms = 1 in tocr (for details, see section 11.2.5, output compare register dm (ocrdm).) icrainput capture register a h'ff98 frt icrbinput capture register b h'ff9a frt icrcinput capture register c h'ff9c frt icrdinput capture register d h'ff9e frt 15 0 r 14 0 r 13 0 r 12 0 r 11 0 r 8 0 r 10 0 r 9 0 r bit initial value read/write 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r stores frc value when input capture signal is input (icrc and icrd can be used for buffer operation. for details, see section 11.2.3, input capture registers a to d (icra to icrd).)
871 dadrahpwm (d/a) data register ah h'ffa0 pwmx dadralpwm (d/a) data register al h'ffa1 pwmx dadrbhpwm (d/a) data register bh h'ffa6 pwmx dadrblpwm (d/a) data register bl h'ffa7 pwmx 15 13 da13 1 r/w 14 12 da12 1 r/w 13 11 da11 1 r/w 12 10 da10 1 r/w 11 9 da9 1 r/w 8 6 da6 1 r/w 10 8 da8 1 r/w 9 7 da7 1 r/w bit (cpu) bit (data) dadra initial value read/write 7 5 da5 1 r/w 6 4 da4 1 r/w 5 3 da3 1 r/w 4 2 da2 1 r/w 3 1 da1 1 r/w 0 ? ? 1 2 0 da0 1 r/w 1 ? cfs 1 r/w dadrh dadrl da13 1 r/w da12 1 r/w da11 1 r/w da10 1 r/w da9 1 r/w da6 1 r/w da8 1 r/w da7 1 r/w dadrb initial value read/write da5 1 r/w da4 1 r/w da3 1 r/w da2 1 r/w da1 1 r/w regs 1 r/w da0 1 r/w cfs 1 r/w register select (dadrb only) 0 dadra and dadrb can be accessed 1 dacr and dacnt can be accessed carrier frequency select 0 base cycle = resolution (t) 64 dadr range is h'0401 to h'fffd 1 base cycle = resolution (t) 256 dadr range is h'0103 to h'ffff d/a conversion data
872 dacrpwm (d/a) control register h'ffa0 pwmx 7 test 0 r/w 6 pwme 0 r/w 5 ? 1 4 ? 1 3 oeb 0 r/w 0 cks 0 r/w 2 oea 0 r/w 1 os 0 r/w bit initial value read/write clock select 0 operates at resolution (t) = system clock cycle time (t cyc ) 1 operates at resolution (t) = system clock cycle time (t cyc ) 2 output select 0 direct pwm output 1 inverted pwm output output enable a 0 pwm (d/a) channel a output (pwx0 output pin) disabled 1 pwm (d/a) channel a output (pwx0 output pin) enabled output enable b 0 pwm (d/a) channel b output (pwx1 output pin) disabled 1 pwm (d/a) channel b output (pwx1 output pin) enabled pwm enable 0 dacnt operates as a 14-bit up-counter 1 dacnt halts at h'0003 test mode 0 pwm (d/a) in user state: normal operation 1 pwm (d/a) in test state: correct conversion results unobtainable
873 dacnthpwm (d/a) counter h h'ffa6 pwmx dacntlpwm (d/a) counter l h'ffa7 pwmx 15 7 0 r/w 14 6 0 r/w 13 5 0 r/w 12 4 0 r/w 11 3 0 r/w 8 0 0 r/w 10 2 0 r/w 9 1 0 r/w bit (cpu) bit (counter) initial value read/write 7 8 0 r/w 6 9 0 r/w 5 10 0 r/w 4 11 0 r/w 3 12 0 r/w 0 ? regs 1 r/w 2 13 0 r/w 1 ? ? 1 dacnth dacntl up-counter register select 0 dadra and dadrb can be accessed 1 dacr and dacnt can be accessed
874 tcsr0timer control/status register 0 h'ffa8 wdt0 7 ovf 0 r/(w) * 6 wt/ it 0 r/w 5 tme 0 r/w 4 rsts 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write tcsr0 clock select 2 to 0 cks2 0 1 ?2 ?64 ?128 ?512 ?2048 ?8192 ?32768 ?131072 cks1 0 1 0 1 cks0 0 1 0 1 0 1 0 1 note: * only 0 can be written, to clear the flag. clock reset or nmi 0 nmi interrupt requested 1 internal reset requested timer enable 0 tcnt is initialized to h'00 and halted 1 tcnt counts reserved bit timer mode select 0 interval timer mode: sends the cpu an interval timer interrupt request (wovi) when tcnt overflows 1 watchdog timer mode: generates a reset or nmi interrupt when tcnt overflows overflow flag 0 [clearing conditions] ? write 0 in the tme bit ? read tcsr when ovf = 1, then write 0 in ovf 1 [setting condition] when tcnt overflows (changes from h'ff to h'00) (when internal reset request generation is selected in watchdog timer mode, ovf is cleared automatically by the internal reset.)
875 tcnt0timer counter 0 h'ffa8 (w), h'ffa9 (r) wdt0 tcnt1timer counter 1 h'ffea (w), h'ffeb (r) wdt1 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write up-counter paodrport a output data register h'ffaa port a 7 pa7odr 0 r/w 6 pa6odr 0 r/w 5 pa5odr 0 r/w 4 pa4odr 0 r/w 3 pa3odr 0 r/w 0 pa0odr 0 r/w 2 pa2odr 0 r/w 1 pa1odr 0 r/w bit initial value read/write output data for port a pins papinport a input data register h'ffab (r) port a 7 pa7pin * r 6 pa6pin * r 5 pa5pin * r 4 pa4pin * r 3 pa3pin * r 0 pa0pin * r 2 pa2pin * r 1 pa1pin * r bit initial value read/write note: * determined by state of pins pa7 to pa0. port a pin states paddrport a data direction register h'ffab (w) port a 7 pa7ddr 0 w 6 pa6ddr 0 w 5 pa5ddr 0 w 4 pa4ddr 0 w 3 pa3ddr 0 w 0 pa0ddr 0 w 2 pa2ddr 0 w 1 pa1ddr 0 w bit initial value read/write specification of input or output for port a pins
876 p1pcrport 1 mos pull-up control register h'ffac port 1 7 p17pcr 0 r/w 6 p16pcr 0 r/w 5 p15pcr 0 r/w 4 p14pcr 0 r/w 3 p13pcr 0 r/w 0 p10pcr 0 r/w 2 p12pcr 0 r/w 1 p11pcr 0 r/w bit initial value read/write control of port 1 built-in mos input pull-ups p2pcrport 2 mos pull-up control register h'ffad port 2 7 p27pcr 0 r/w 6 p26pcr 0 r/w 5 p25pcr 0 r/w 4 p24pcr 0 r/w 3 p23pcr 0 r/w 0 p20pcr 0 r/w 2 p22pcr 0 r/w 1 p21pcr 0 r/w bit initial value read/write control of port 2 built-in mos input pull-ups p3pcrport 3 mos pull-up control register h'ffae port 3 7 p37pcr 0 r/w 6 p36pcr 0 r/w 5 p35pcr 0 r/w 4 p34pcr 0 r/w 3 p33pcr 0 r/w 0 p30pcr 0 r/w 2 p32pcr 0 r/w 1 p31pcr 0 r/w bit initial value read/write control of port 3 built-in mos input pull-ups p1ddrport 1 data direction register h'ffb0 port 1 7 p17ddr 0 w 6 p16ddr 0 w 5 p15ddr 0 w 4 p14ddr 0 w 3 p13ddr 0 w 0 p10ddr 0 w 2 p12ddr 0 w 1 p11ddr 0 w bit initial value read/write specification of input or output for port 1 pins
877 p2ddrport 2 data direction register h'ffb1 port 2 7 p27ddr 0 w 6 p26ddr 0 w 5 p25ddr 0 w 4 p24ddr 0 w 3 p23ddr 0 w 0 p20ddr 0 w 2 p22ddr 0 w 1 p21ddr 0 w bit initial value read/write specification of input or output for port 2 pins p1drport 1 data register h'ffb2 port 1 7 p17dr 0 r/w 6 p16dr 0 r/w 5 p15dr 0 r/w 4 p14dr 0 r/w 3 p13dr 0 r/w 0 p10dr 0 r/w 2 p12dr 0 r/w 1 p11dr 0 r/w bit initial value read/write output data for port 1 pins p2drport 2 data register h'ffb3 port 2 7 p27dr 0 r/w 6 p26dr 0 r/w 5 p25dr 0 r/w 4 p24dr 0 r/w 3 p23dr 0 r/w 0 p20dr 0 r/w 2 p22dr 0 r/w 1 p21dr 0 r/w bit initial value read/write output data for port 2 pins p3ddrport 3 data direction register h'ffb4 port 3 7 p37ddr 0 w 6 p36ddr 0 w 5 p35ddr 0 w 4 p34ddr 0 w 3 p33ddr 0 w 0 p30ddr 0 w 2 p32ddr 0 w 1 p31ddr 0 w bit initial value read/write specification of input or output for port 3 pins
878 p4ddrport 4 data direction register h'ffb5 port 4 7 p47ddr 0 w 6 p46ddr 0 w 5 p45ddr 0 w 4 p44ddr 0 w 3 p43ddr 0 w 0 p40ddr 0 w 2 p42ddr 0 w 1 p41ddr 0 w bit initial value read/write specification of input or output for port 4 pins p3drport 3 data register h'ffb6 port 3 7 p37dr 0 r/w 6 p36dr 0 r/w 5 p35dr 0 r/w 4 p34dr 0 r/w 3 p33dr 0 r/w 0 p30dr 0 r/w 2 p32dr 0 r/w 1 p31dr 0 r/w bit initial value read/write output data for port 3 pins p4drport 4 data register h'ffb7 port 4 7 p47dr 0 r/w 6 p46dr 0 r/w 5 p45dr 0 r/w 4 p44dr 0 r/w 3 p43dr 0 r/w 0 p40dr 0 r/w 2 p42dr 0 r/w 1 p41dr 0 r/w bit initial value read/write output data for port 4 pins p5ddrport 5 data direction register h'ffb8 port 5 7 ? 1 6 ? 1 5 ? 1 4 ? 1 3 ? 1 0 p50ddr 0 w 2 p52ddr 0 w 1 p51ddr 0 w bit initial value read/write specification of input or output for port 5 pins
879 p6ddrport 6 data direction register h'ffb9 port 6 7 p67ddr 0 w 6 p66ddr 0 w 5 p65ddr 0 w 4 p64ddr 0 w 3 p63ddr 0 w 0 p60ddr 0 w 2 p62ddr 0 w 1 p61ddr 0 w bit initial value read/write specification of input or output for port 6 pins p5drport 5 data register h'ffba port 5 7 ? 1 6 ? 1 5 ? 1 4 ? 1 3 ? 1 0 p50dr 0 r/w 2 p52dr 0 r/w 1 p51dr 0 r/w bit initial value read/write output data for port 5 pins p6drport 6 data register h'ffbb port 6 7 p67dr 0 r/w 6 p66dr 0 r/w 5 p65dr 0 r/w 4 p64dr 0 r/w 3 p63dr 0 r/w 0 p60dr 0 r/w 2 p62dr 0 r/w 1 p61dr 0 r/w bit initial value read/write output data for port 6 pins pbodrport b output data register h'ffbc port b 7 pb7odr 0 r/w 6 pb6odr 0 r/w 5 pb5odr 0 r/w 4 pb4odr 0 r/w 3 pb3odr 0 r/w 0 pb0odr 0 r/w 2 pb2odr 0 r/w 1 pb1odr 0 r/w bit initial value read/write output data for port b pins
880 p8ddrport 8 data direction register h'ffbd (w) port 8 7 ? 1 6 p86ddr 0 w 5 p85ddr 0 w 4 p84ddr 0 w 3 p83ddr 0 w 0 p80ddr 0 w 2 p82ddr 0 w 1 p81ddr 0 w bit initial value read/write specification of input or output for port 8 pins pbpinport b input data register h'ffbd (r) port b 7 pb7pin * r 6 pb6pin * r 5 pb5pin * r 4 pb4pin * r 3 pb3pin * r 0 pb0pin * r 2 pb2pin * r 1 pb1pin * r bit initial value read/write note: * determined by state of pins pb7 to pb0. port b pin states pbddrport b data direction register h'ffbe (w) port b 7 pb7ddr 0 w 6 pb6ddr 0 w 5 pb5ddr 0 w 4 pb4ddr 0 w 3 pb3ddr 0 w 0 pb0ddr 0 w 2 pb2ddr 0 w 1 pb1ddr 0 w bit initial value read/write specification of input or output for port b pins p7pinport 7 input data register h'ffbe (r) port 7 7 p77pin * r 6 p76pin * r 5 p75pin * r 4 p74pin * r 3 p73pin * r 0 p70pin * r 2 p72pin * r 1 p71pin * r bit initial value read/write note: * determined by state of pins p77 to p70. port 7 pin states
881 p8drport 8 data register h'ffbf port 8 7 ? 1 6 p86dr 0 r/w 5 p85dr 0 r/w 4 p84dr 0 r/w 3 p83dr 0 r/w 0 p80dr 0 r/w 2 p82dr 0 r/w 1 p81dr 0 r/w bit initial value read/write output data for port 8 pins p9ddrport 9 data direction register h'ffc0 port 9 7 p97ddr 0 w 0 w 6 p96ddr 1 w 0 w 5 p95ddr 0 w 0 w 4 p94ddr 0 w 0 w 3 p93ddr 0 w 0 w 0 p90ddr 0 w 0 w 2 p92ddr 0 w 0 w 1 p91ddr 0 w 0 w bit mode 1 initial value read/write modes 2 and 3 initial value read/write specification of input or output for port 9 pins p9drport 9 data register h'ffc1 port 9 7 p97dr 0 r/w 6 p96dr * r 5 p95dr 0 r/w 4 p94dr 0 r/w 3 p93dr 0 r/w 0 p90dr 0 r/w 2 p92dr 0 r/w 1 p91dr 0 r/w bit initial value read/write note: * determined by state of pin p96. output data for port 9 pins
882 ierirq enable register h'ffc2 interrupt controller 7 irq7e 0 r/w 6 irq6e 0 r/w 5 irq5e 0 r/w 4 irq4e 0 r/w 3 irq3e 0 r/w 0 irq0e 0 r/w 2 irq2e 0 r/w 1 irq1e 0 r/w bit initial value read/write irq7 to irq0 enable 0 irqn interrupt disabled 1 irqn interrupt enabled (n = 7 to 0)
883 stcrserial timer control register h'ffc3 system 7 iics 0 r/w 6 iicx1 0 r/w 5 iicx0 0 r/w 4 iice 0 r/w 3 flshe 0 r/w 0 icks0 0 r/w 2 ? 0 r/w 1 icks1 0 r/w bit initial value read/write notes: 1. 2. internal clock source select * 1 reserved bit flash memory control register enable 0 flash memory control register not selected 1 flash memory control register selected i 2 c master enable 0 cpu access to sci0, sci1, and sci2 control registers is enabled 1 cpu access to i 2 c bus interface data, pwmx and control registers is enabled 0 pa7 to pa4 are normal i/o pins 1 pa7 to pa4 are i/o pins with bus driving capability i 2 c transfer select 1 and 0 * 2 i 2 c extra buffer select used for 8-bit timer input clock selection. for details, see section 12.2.4, timer control register (tcr). used for i 2 c bus interface transfer clock selection. for details, see section 16.2.4, i 2 c bus mode register (icmr).
884 syscrsystem control register h'ffc4 system 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write ram enable 0 on-chip ram is disabled 1 on-chip ram is enabled host interface enable 0 addresses h'(ff)fff0 to h'(ff)fff7 and h'(ff)fffc to h'(ff)ffff are used for access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers 1 addresses h'(ff)fff0 to h'(ff)fff7 and h'(ff)fffc to h'(ff)ffff are used for access to host interface data registers and control registers, and keyboard controller and mos input pull-up control registers nmi edge select 0 falling edge 1 rising edge external reset 0 reset generated by watchdog timer overflow 1 reset generated by an external reset interrupt control mode select intm1 interrupt control mode 0 interrupt control mode 1 intm0 description 00 1 cs2 enable 0 cs2 pin function halted ( cs2 fixed high internally) 0 cs2e fga20e 1 1 cs2 pin function selected for p81/ cs2 pin 0 cs2 pin function selected for p90/ ecs2 pin 1 description syscr bit 7 hicr bit 0 ios enable 0 the as / ios pin functions as the address strobe pin (low output when accessing an external area) 1 the as / ios pin functions as the i/o strobe pin (low output when accessing a specified address from h'(ff)f000 to h'(ff)fe4f)
885 mdcrmode control register h'ffc5 system 7 expe * r/w * 6 ? 0 5 ? 0 4 ? 0 3 ? 0 0 mds0 * r 2 ? 0 1 mds1 * r bit initial value read/write expanded mode enable 0 single-chip mode selected 1 expanded mode selected note: * determined by the md1 and md0 pins. mode select 1 and 0
886 bcrbus control register h'ffc6 bus controller 7 icis1 1 r/w 6 icis0 1 r/w 5 brstrm 0 r/w 4 brsts1 1 r/w 3 brsts0 0 r/w 0 ios0 1 r/w 2 ? 1 r/w 1 ios1 1 r/w bit initial value read/write ios select ios1 address for which as / ios pin output goes low when iose = 1 0 low in access to address h'(ff)f000 to h'(ff)f03f ios0 0 low in access to address h'(ff)f000 to h'(ff)f0ff 1 1 low in access to address h'(ff)f000 to h'(ff)f3ff 0 low in access to address h'(ff)f000 to h'(ff)fe4f 1 burst cycle select 0 0 max. 4 words in burst access 1 max. 8 words in burst access burst cycle select 1 0 burst cycle comprises 1 state 1 burst cycle comprises 2 states burst rom enable 0 basic bus interface 1 burst rom interface idle cycle insert 0 0 idle cycle not inserted in case of successive external read and external write cycles 1 idle cycle inserted in case of successive external read and external write cycles reserved bit
887 wscrwait state control register h'ffc7 bus controller 7 rams 0 r/w 6 ram0 0 r/w 5 abw 1 r/w 4 ast 1 r/w 3 wms1 0 r/w 0 wc0 1 r/w 2 wms0 0 r/w 1 wc1 1 r/w bit initial value read/write reserved bits wait count 1 and 0 0 no program wait states are inserted 0 1 program wait state is inserted in external memory space accesses 1 1 2 program wait states are inserted in external memory space accesses 0 3 program wait states are inserted in external memory space accesses 1 wait mode select 1 and 0 0 program wait mode 0 wait disabled mode 1 1 pin wait mode 0 pin auto-wait mode 1 access state control 0 external memory space is designated as 2-state access space wait state insertion in external memory space accesses is disabled 1 external memory space is designated as 3-state access space wait state insertion in external memory space accesses is enabled bus width control 0 external memory space designated as 16-bit access space 1 external memory space designated as 8-bit access space
888 tcr0timer control register 0 h'ffc8 tmr0 tcr1timer control register 1 h'ffc9 tmr1 tcrxtimer control register x h'fff0 tmrx tcrytimer control register y h'fff0 tmry 7 cmieb 0 r/w 6 cmiea 0 r/w 5 ovie 0 r/w 4 cclr1 0 r/w 3 cclr0 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write clock select 2 to 0 channel bit 2 bit 1 bit 0 cks2 0 1 x y all 0 1 0 1 0 1 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 cks1 cks0 description clock input disabled internal clock: counting at falling edge of ?8 internal clock: counting at falling edge of ?2 internal clock: counting at falling edge of ?64 internal clock: counting at falling edge of ?32 internal clock: counting at falling edge of ?1024 internal clock: counting at falling edge of ?256 counting at tcnt1 overflow signal * 2 clock input disabled internal clock: counting at falling edge of ?8 internal clock: counting at falling edge of ?2 internal clock: counting at falling edge of ?64 internal clock: counting at falling edge of ?128 internal clock: counting at falling edge of ?1024 internal clock: counting at falling edge of ?2048 count at tcnt0 compare match a * 2 clock input disabled internal clock: counting on ? internal clock: counting at falling edge of ?2 internal clock: counting at falling edge of ?4 clock input disabled clock input disabled internal clock: counting at falling edge of ?4 internal clock: counting at falling edge of ?256 internal clock: counting at falling edge of ?2048 clock input disabled external clock: counting at rising edge external clock: counting at falling edge external clock: counting at both rising and falling edges * 1 * 1 * 1 * 1 * 1 * 1 notes: 1. 2. selected by icks1 and icks0 in stcr. for details, see section 12.2.4, timer control register (tcr). if the clock input of channel 0 is the tcnt1 overflow signal and that of channel 1 is the tcnt0 compare match signal, no incrementing clock is generated. do not use this setting. counter clear 1 and 0 0 clear is disabled cleared on compare match a 0 1 1 cleared on compare match b 0 cleared on rising edge of external reset input 1 timer overflow interrupt enable 0 ovf interrupt request (ovi) is disabled 1 ovf interrupt request (ovi) is enabled compare match interrupt enable a 0 cmfa interrupt request (cmia) is disabled 1 cmfa interrupt request (cmia) is enabled compare match interrupt enable b 0 cmfb interrupt request (cmib) is disabled 1 cmfb interrupt request (cmib) is enabled
889 tcsr0timer control/status register 0 h'ffca tmr0 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 adte 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsr0 output select 1 and 0 0 no change at compare match a 0 0 output at compare match a 1 1 1 output at compare match a 0 output inverted at compare match a (toggle output) 1 note: output select 3 and 2 0 no change at compare match b 0 0 output at compare match b 1 1 1 output at compare match b 0 output inverted at compare match b (toggle output) 1 a/d trigger enable 0 a/d converter start requests by compare match a are disabled 1 a/d converter start requests by compare match a are enabled timer overflow flag 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] when tcnt overflows from h'ff to h'00 compare match flag a 0 [clearing conditions] ? read cmfa when cmfa = 1, then write 0 in cmfa ? when the dtc is activated by a cmia interrupt 1 [setting condition] when tcnt = tcora compare match flag b 0 [clearing conditions] ? read cmfb when cmfb = 1, then write 0 in cmfb ? when the dtc is activated by a cmib interrupt 1 [setting condition] when tcnt = tcorb * only 0 can be written in bits 7 to 5, to clear the flags.
890 tcsr1timer control/status register 1 h'ffcb tmr1 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 ? 1 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsr1 output select 1 and 0 0 no change at compare match a 0 0 output at compare match a 1 1 1 output at compare match a 0 output inverted at compare match a (toggle output) 1 output select 3 and 2 0 no change at compare match b 0 0 output at compare match b 1 1 1 output at compare match b 0 output inverted at compare match b (toggle output) 1 timer overflow flag 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] when tcnt overflows from h'ff to h'00 compare match flag a 0 [clearing conditions] ? read cmfa when cmfa = 1, then write 0 in cmfa ? when the dtc is activated by a cmia interrupt 1 [setting condition] when tcnt = tcora compare match flag b 0 [clearing conditions] ? read cmfb when cmfb = 1, then write 0 in cmfb ? when the dtc is activated by a cmib interrupt 1 [setting condition] when tcnt = tcorb note: * only 0 can be written in bits 7 to 5, to clear the flags.
891 tcora0time constant register a0 h'ffcc tmr0 tcora1time constant register a1 h'ffcd tmr1 tcorb0time constant register b0 h'ffce tmr0 tcorb1time constant register b1 h'ffcf tmr1 tcoraytime constant register ay h'fff2 tmry tcorbytime constant register by h'fff3 tmry tcorctime constant register c h'fff5 tmrx tcoraxtime constant register ax h'fff6 tmrx tcorbxtime constant register bx h'fff7 tmrx 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write 15 1 r/w bit initial value read/write 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w tcora0 tcorb0 tcora1 tcorb1 compare match flag (cmf) is set when tcor and tcnt values match compare match flag (cmf) is set when tcor and tcnt values match 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write compare match c signal is generated when sum of tcorc and ticr contents match tcnt value tcorax, tcoray tcorbx, tcorby tcorc
892 tcnt0timer counter 0 h'ffd0 tmr0 tcnt1timer counter 1 h'ffd1 tmr1 tcntxtimer counter x h'fff4 tmrx tcntytimer counter y h'fff4 tmry 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write up-counter 15 0 r/w bit initial value read/write 14 0 r/w 13 0 r/w 12 0 r/w 11 0 r/w 10 0 r/w 9 0 r/w 8 0 r/w 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 2 0 r/w 1 0 r/w 0 0 r/w tcnt0 tcnt1 up-counter tcntx, tcnty
893 pwoerapwm output enable register a h'ffd3 pwm pwoerbpwm output enable register b h'ffd2 pwm 7 oe7 0 r/w 6 oe6 0 r/w 5 oe5 0 r/w 4 oe4 0 r/w 3 oe3 0 r/w 0 oe0 0 r/w 2 oe2 0 r/w 1 oe1 0 r/w bit pwoera initial value read/write 7 oe15 0 r/w 6 oe14 0 r/w 5 oe13 0 r/w 4 oe12 0 r/w 3 oe11 0 r/w switching between pwm output and port output 0 oe8 0 r/w 2 oe10 0 r/w 1 oe9 0 r/w bit pwoerb initial value read/write 0 1 0 1 0 1 port input port input port output or pwm 256/256 output pwm output (0 to 255/256 output) ddr oe description pwdprapwm data polarity register a h'ffd5 pwm pwdprbpwm data polarity register b h'ffd4 pwm 7 os7 0 r/w 6 os6 0 r/w 5 os5 0 r/w 4 os4 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit pwdpra initial value read/write 7 os15 0 r/w 6 os14 0 r/w 5 os13 0 r/w 4 os12 0 r/w 3 os11 0 r/w 0 os8 0 r/w 2 os10 0 r/w 1 os9 0 r/w bit pwdprb initial value read/write pwm output polarity control 0 pwm direct output (pwdr value corresponds to high width of output) 1 pwm inverted output (pwdr value corresponds to low width of output)
894 pwslpwm register select h'ffd6 pwm 7 pwcke 0 r/w 6 pwcks 0 r/w 5 ? 1 4 ? 0 3 rs3 0 r/w 0 rs0 0 r/w 2 rs2 0 r/w 1 rs1 0 r/w bit initial value read/write 0 1 pwdr0 selected pwdr1 selected pwdr2 selected pwdr3 selected pwdr4 selected pwdr5 selected pwdr6 selected pwdr7 selected pwdr8 selected pwdr9 selected pwdr10 selected pwdr11 selected pwdr12 selected pwdr13 selected pwdr14 selected pwdr15 selected register select 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 pwm clock enable, pwm clock select clock input disabled ?(system clock) selected ?2 selected ?4 selected ?8 selected ?16 selected pwsl pcsr bit 2 pwckb ? ? 0 1 bit 1 pwcka ? ? 0 1 0 1 bit 7 pwcke 0 1 bit 6 pwcks ? 0 1 description
895 pwdr0 to pwdr15pwm data registers h'ffd7 pwm 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w specifies duty factor of basic output pulse and number of additional pulses 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write addraha/d data register ah h'ffe0 a/d converter addrala/d data register al h'ffe1 a/d converter addrbha/d data register bh h'ffe2 a/d converter addrbla/d data register bl h'ffe3 a/d converter addrcha/d data register ch h'ffe4 a/d converter addrcla/d data register cl h'ffe5 a/d converter addrdha/d data register dh h'ffe6 a/d converter addrdla/d data register dl h'ffe7 a/d converter 14 ad8 0 r 12 ad6 0 r 10 ad4 0 r 8 ad2 0 r 6 ad0 0 r 0 ? 0 r 4 ? 0 r 2 ? 0 r 15 ad9 0 r 13 ad7 0 r 11 ad5 0 r 9 ad3 0 r 7 ad1 0 r 1 ? 0 r 5 ? 0 r 3 ? 0 r bit initial value read/write addrh stores a/d data correspondence between analog input channels and addr registers addrl addra addrb addrc addrd group 0 an0 an1 an2 an3 group 1 an4 an5 an6 or cin0 to cin7 an7 or cin8 to cin15 analog input channel a/d data register
896 adcsra/d control/status register h'ffe8 a/d converter 7 adf 0 r/(w) 6 adie 0 r/w 5 adst 0 r/w 4 scan 0 r/w 3 cks 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w * bit initial value read/write channel select 0 1 0 1 0 1 0 1 0 1 0 1 an0 an1 an2 an3 an4 an5 an6 or cin0 to 7 an7 or cin8 to 15 description an0 an0, an1 an0, an1, an2 an0, an1, an2, an3 an4 an4, an5 an4, an5, an6 or cin0 to 7 an4, an5, an6 or cin0 to 7, an7 or cin8 to 15 group selection ch1 ch0 single mode scan mode ch2 0 1 note: * only 0 can be written, to clear the flag. channel selection clock select 0 conversion time = 266 states (max.) 1 conversion time = 134 states (max.) scan mode 0 single mode 1 scan mode a/d interrupt enable 0 a/d conversion end interrupt (adi) request disabled 1 a/d conversion end interrupt (adi) request enabled a/d end flag 0 [clearing conditions] ? when 0 is written in the to adf flag after reading adf = 1 ? when the dtc is activated by an adi interrupt, and addr is read 1 [setting conditions] ? single mode: when a/d conversion ends ? scan mode: when a/d conversion ends on all specified channels a/d start 0 a/d conversion stopped 1 single mode: a/d conversion is started. cleared to 0 automatically when conversion on the specified channel ends ? scan mode: a/d conversion is started. conversion continues sequentially on the selected channels until adst is cleared to 0 by software, a reset, or a transition to standby mode or module stop mode
897 adcra/d control register h'ffe9 a/d converter 7 trgs1 0 r/w 6 trgs0 0 r/w 5 ? 1 4 ? 1 3 ? 1 0 ? 1 2 ? 1 1 ? 1 bit initial value read/write timer trigger select 0 start of a/d conversion by external trigger is disabled start of a/d conversion by external trigger is disabled start of a/d conversion by external trigger (8-bit timer) is enabled start of a/d conversion by external trigger pin is enabled 0 1 10 1
898 tcsr1timer control/status register 1 h'ffea wdt1 7 ovf 0 r/(w) * 1 6 wt/ it 0 r/w 5 tme 0 r/w 4 pss 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write tcsr1 clock select 2 to 0 pss 0 1 clock cks2 0 1 0 1 cks1 0 1 0 1 0 1 0 1 cks0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 notes: 1. 2. ?2 ?64 ?128 ?512 ?2048 ?8192 ?32768 ?131072 ?ub/2 ?ub/4 ?ub/8 ?ub/16 ?ub/32 ?ub/64 ?ub/128 ?ub/256 reset or nmi 0 nmi interrupt requested 1 internal reset requested prescaler select * 2 0 tcnt counts on a ?based prescaler (psm) scaled clock 1 tcnt counts on a ?ub-based prescaler (pss) scaled clock timer enable 0 tcnt is initialized to h'00 and halted 1 tcnt counts timer mode select 0 interval timer mode: interval timer interrupt request (wovi) sent to cpu when tcnt overflows 1 watchdog timer mode: reset or nmi interrupt request sent to cpu when tcnt overflows overflow flag 0 [clearing conditions] ? when 0 is written in the tme bit ? when 0 is written in ovf after reading tcsr when ovf = 1 1 [setting condition] when tcnt overflows from h'ff to h'00 when internal reset request is selected in watchdog timer mode, ovf is cleared automatically by an internal reset after being set only 0 can be written, to clear the flag. for operation control when a transition is made to power-down mode, see section 24.2.3, timer control/status register (tcsr).
899 hicrhost interface control register h'fff0 hif 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 fga20e 0 r/w 2 ibfie2 0 r/w 1 ibfie1 0 r/w bit initial value slave r/w host r/w fast gate a20 enable 0 fast gate a20 function disabled 1 fast gate a20 function enabled input data register full interrupt enable 1 0 input data register (idr1) receive complete interrupt is disabled 1 input data register (idr1) receive complete interrupt is enabled input data register full interrupt enable 2 0 input data register (idr2) receive complete interrupt is disabled 1 input data register (idr2) receive complete interrupt is enabled
900 tcsrxtimer control/status register x h'fff1 tmrx 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 icf 0 r/(w) * 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsrx output select 1 and 0 0 no change at compare match a 0 0 output at compare match a 1 1 1 output at compare match a 0 output inverted at compare match a (toggle output) 1 note: output select 3 and 2 0 no change at compare match b 0 0 output at compare match b 1 1 1 output at compare match b 0 output inverted at compare match b (toggle output) 1 input capture flag 0 [clearing condition] when 0 is written in icf after reading icf = 1 1 [setting condition] when a rising edge followed by a falling edge is detected in the external reset signal after the icst bit in tconri has been set to 1 timer overflow flag 0 [clearing condition] when 0 is written in ovf after reading ovf = 1 1 [setting condition] when tcnt overflows from h'ff to h'00 compare match flag a 0 [clearing conditions] ? when 0 is written in cmfa after reading cmfa = 1 ? when the dtc is activated by a cmia interrupt 1 [setting condition] when tcnt = tcora compare match flag b 0 [clearing conditions] ? when 0 is written in cmfb after reading cmfb = 1 ? when the dtc is activated by a cmib interrupt 1 [setting condition] when tcnt = tcorb * only 0 can be written in bits 7 to 4, to clear the flags.
901 tcsrytimer control/status register y h'fff1 tmry 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 icie 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsry output select 1 and 0 0 no change at compare match a 0 0 output at compare match a 1 1 1 output at compare match a 0 output inverted at compare match a (toggle output) 1 note: output select 3 and 2 0 no change at compare match b 0 0 output at compare match b 1 1 1 output at compare match b 0 output inverted at compare match b (toggle output) 1 input capture interrupt enable 0 interrupt request by icf (icix) is disabled 1 interrupt request by icf (icix) is enabled timer overflow flag 0 [clearing condition] when 0 is written in ovf after reading ovf = 1 1 [setting condition] when tcnt overflows from h'ff to h'00 compare match flag a 0 [clearing conditions] ? when 0 is written in cmfa after reading cmfa = 1 ? when the dtc is activated by a cmia interrupt 1 [setting condition] when tcnt = tcora compare match flag b 0 [clearing conditions] ? when 0 is written in cmfb after reading cmfb = 1 ? when the dtc is activated by a cmib interrupt 1 [setting condition] when tcnt = tcorb * only 0 can be written in bits 7 to 5, to clear the flags.
902 kmimrkeyboard matrix interrupt mask register h'fff1 interrupt controller kmimrakeyboard matrix interrupt mask register a h'fff3 interrupt controller 7 kmimr7 1 r/w 6 kmimr6 0 r/w 5 kmimr5 1 r/w 4 kmimr4 1 r/w 3 kmimr3 1 r/w 0 kmimr0 1 r/w 2 kmimr2 1 r/w 1 kmimr1 1 r/w bit initial value read/write kmimr 7 kmimr15 1 r/w 6 kmimr14 1 r/w 5 kmimr13 1 r/w 4 kmimr12 1 r/w 3 kmimr11 1 r/w 0 kmimr8 1 r/w 2 kmimr10 1 r/w 1 kmimr9 1 r/w bit initial value read/write kmimra keyboard matrix interrupt mask 0 key-sense input interrupt requests enabled 1 key-sense input interrupt requests disabled keyboard matrix interrupt mask 0 key-sense input interrupt requests enabled 1 key-sense input interrupt requests disabled ticrrinput capture register r h'fff2 tmrx ticrfinput capture register f h'fff3 tmrx 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r bit initial value read/write stores tcnt value at fall of external trigger input
903 kmpcrport 6 mos pull-up control register h'fff2 port 6 7 km7pcr 0 r/w 6 km6pcr 0 r/w 5 km5pcr 0 r/w 4 km4pcr 0 r/w 3 km3pcr 0 r/w 0 km0pcr 0 r/w 2 km2pcr 0 r/w 1 km1pcr 0 r/w bit initial value read/write control of port 6 built-in mos input pull-ups note: kmpcr has the same address as ticrr/tcoray of tmrx/tmry. when selecting kmpcr, set the hie bit to 1 in syscr. idr1input data register 1 h'fff4 hif idr2input data register 2 h'fffc hif 7 idr7 ? r w 6 idr6 ? r w 5 idr5 ? r w 4 idr4 ? r w 3 idr3 ? r w 0 idr0 ? r w 2 idr2 ? r w 1 idr1 ? r w bit initial value slave r/w host r/w stores host data bus contents at rise of iow when cs is low odr1output data register 1 h'fff5 hif odr2output data register 2 h'fffd hif 7 odr7 ? r/w r 6 odr6 ? r/w r 5 odr5 ? r/w r 4 odr4 ? r/w r 3 odr3 ? r/w r 0 odr0 ? r/w r 2 odr2 ? r/w r 1 odr1 ? r/w r bit initial value slave r/w host r/w odr contents are output to the host data bus when ha0 is low, cs is low, and ior is low
904 tisrtimer input select register h'fff5 tmry 7 ? 1 6 ? 1 5 ? 1 4 ? 1 3 ? 1 0 is 0 r/w 2 ? 1 1 ? 1 bit initial value read/write input select 0 1 ivg signal is selected (h8s/2148 series) external clock/reset input is disabled (h8s/2144 series) vsynci/tmiy (tmciy/tmriy) is selected str1status register 1 h'fff6 hif str2status register 2 h'fffe hif 7 dbu 0 r/w r 6 dbu 0 r/w r 5 dbu 0 r/w r 4 dbu 0 r/w r 3 c/ d 0 r r 0 obf 0 r r 2 dbu 0 r/w r 1 ibf 0 r r bit initial value slave r/w host r/w output buffer full 0 [clearing condition] when the host processor reads odr 1 [setting condition] when the slave processor writes to odr user-defined bits input buffer full 0 [clearing condition] when the slave processor reads idr 1 [setting condition] when the host processor writes to idr command/data 0 contents of input data register (idr) are data 1 contents of input data register (idr) are a command
905 dadr0d/a data register 0 h'fff8 d/a converter dadr1d/a data register 1 h'fff9 d/a converter 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write stores data for d/a conversion dacrd/a control register h'fffa d/a converter 7 daoe1 0 r/w 6 daoe0 0 r/w 5 dae 0 r/w 4 ? 1 3 ? 1 0 ? 1 2 ? 1 1 ? 1 bit initial value read/write d/a enabled daoe1 0 conversion result dae * 0 1 0 1 * 1 0 1 daoe0 0 1 channel 0 and 1 d/a conversion disabled channel 0 d/a conversion enabled channel 1 d/a conversion disabled channel 0 and 1 d/a conversion enabled channel 0 d/a conversion disabled channel 1 d/a conversion enabled channel 0 and 1 d/a conversion enabled channel 0 and 1 d/a conversion enabled * : don? care d/a output enable 0 0 analog output da0 disabled 1 d/a conversion is enabled on channel 0. analog output da0 is enabled d/a output enable 1 0 analog output da1 disabled 1 d/a conversion is enabled on channel 1. analog output da1 is enabled
906 tconritimer connection register i h'fffc timer connection bit initial value read/write 7 simod1 0 r/w 6 simod0 0 r/w 5 scone 0 r/w 4 icst 0 r/w 3 hfinv 0 r/w 0 viinv 0 r/w 2 vfinv 0 r/w 1 hiinv 0 r/w input synchronization mode select 1 and 0 0 1 no signal s-on-g mode composite mode separate mode 0 1 0 1 simod1 mode hfbacki input csynci input hsynci input hsynci input ihi signal vfbacki input pdc input pdc input vsynci input ivi signal simod0 synchronization signal connection enable 0 1 ftia input normal connection scone ftia ftib ftic ftid tmci1 tmri1 mode ftib input ftic input tmci1 input tmri1 input ftid input ivi signal synchronization signal connec- tion mode tmo1 signal vfbacki input ihi signal ivi inverse signal ihi signal input synchronization signal inversion 0 the vsynci pin state is used directly as the vsynci input 1 the vsynci pin state is inverted before use as the vsynci input input synchronization signal inversion 0 the hsynci and csynci pin states are used directly as the hsynci and csynci inputs 1 the hsynci and csynci pin states are inverted before use as the hsynci and csynci inputs input synchronization signal inversion 0 the vfbacki pin state is used directly as the vfbacki input 1 the vfbacki pin state is inverted before use as the vfbacki input input capture start bit 0 the ticrr and ticrf input capture functions are stopped [clearing condition] when a rising edge followed by a falling edge is detected on tmrix 1 the ticrr and ticrf input capture functions are operating (waiting for detection of a rising edge followed by a falling edge on tmrix) [setting condition] when 1 is written in icst after reading icst = 0 input synchronization signal inversion 0 the hfbacki pin state is used directly as the hfbacki input 1 the hfbacki pin state is inverted before use as the hfbacki input
907 tconrotimer connection register o h'fffd timer connection bit initial value read/write 7 hoe 0 r/w 6 voe 0 r/w 5 cloe 0 r/w 4 cboe 0 r/w 3 hoinv 0 r/w 0 cboinv 0 r/w 2 voinv 0 r/w 1 cloinv 0 r/w output synchronization signal inversion 0 the cblank signal is used directly as the cblank output 1 the cblank signal is inverted before use as the cblank output output synchronization signal inversion 0 the clo signal (cl1, cl2, cl3, or cl4 signal) is used directly as the clampo output 1 the clo signal (cl1, cl2, cl3, or cl4 signal) is inverted before use as the clampo output output synchronization signal inversion 0 the ivo signal is used directly as the vsynco output 1 the ivo signal is inverted before use as the vsynco output output synchronization signal inversion 0 the iho signal is used directly as the hsynco output 1 the iho signal is inverted before use as the hsynco output output enable 0 the p27/a15/pw15/cblank pin functions as the p27/a15/pw15 pin 1 in mode 1 (expanded mode with on-chip rom disabled): the p27/a15/pw15/cblank pin functions as the a15 pin in modes 2 and 3 (expanded modes with on-chip rom enabled): the p27/a15/pw15/cblank pin functions as the cblank pin output enable 0 the p64/ftic/ kin4 /cin4/clampo pin functions as the p64/ftic/ kin4 /cin4 pin 1 the p64/ftic/ kin4 /cin4/clampo pin functions as the clampo pin output enable 0 the p61/ftoa/ kin1 /cin1/vsynco pin functions as the p61/ftoa/ kin1 /cin1 pin 1 the p61/ftoa/ kin1 /cin1/vsynco pin functions as the vsynco pin output enable 0 the p44/tmo1/hirq1/hsynco pin functions as the p44/tmo1/hirq1 pin 1 the p44/tmo1/hirq1/hsynco pin functions as the hsynco pin
908 tconrstimer connection register s h'fffe timer connection 7 tmrx/y 0 r/w 6 isgene 0 r/w 5 homod1 0 r/w 4 homod0 0 r/w 3 vomod1 0 r/w 0 clmod0 0 r/w 2 vomod0 0 r/w 1 clmod1 0 r/w bit initial value read/write clamp waveform mode select 1 and 0 clmod1 clmod0 0 1 0 1 0 1 0 1 0 1 0 1 description the cl1 signal is selected the cl2 signal is selected the cl3 signal is selected the cl4 signal is selected isgene 0 1 vertical synchronization output mode select 1 and 0 vomod1 vomod0 0 1 0 1 0 1 0 1 0 1 0 1 description isgene 0 1 horizontal synchronization output mode select 1 and 0 homod1 homod0 0 1 0 1 0 1 0 1 0 1 0 1 description the ihi signal (without 2fh modification) is selected the ihi signal (with 2fh modification) is selected the cl1 signal is selected the ihg signal is selected isgene 0 1 the ivi signal (without fall modification or ihi synchronization) is selected the ivi signal (without fall modification, with ihi synchronization) is selected the ivi signal (with fall modification, without ihi synchronization) is selected the ivi signal (with fall modification and ihi synchronization) is selected the ivg signal is selected internal synchronization signal select tmrx/tmry access select 0 the tmrx registers are accessed at addresses h'fff0 to h'fff5 1 the tmry registers are accessed at addresses h'fff0 to h'fff5
909 sedgredge sense register h'ffff timer connection bit initial value read/write 7 vedg 0 r/(w) 6 hedg 0 r/(w) 5 cedg 0 r/(w) 4 hfedg 0 r/(w) 3 vfedg 0 r/(w) 0 ivi * 2 r 2 preqf 0 r/(w) 1 ihi * 2 r * 1 * 1 * 1 * 1 * 1 * 1 ivi signal level 0 the ivi signal is low 1 the ivi signal is high notes: 1. 2. ihi signal level 0 the ihi signal is low 1 the ihi signal is high pre-equalization flag 0 [clearing condition] when 0 is written in preqf after reading preqf = 1 1 [setting condition] when an ihi signal 2fh modification condition is detected vfbacki edge 0 [clearing condition] when 0 is written in vfedg after reading vfedg = 1 1 [setting condition] when a rising edge is detected on the vfbacki pin hfbacki edge 0 [clearing condition] when 0 is written in hfedg after reading hfedg = 1 1 [setting condition] when a rising edge is detected on the hfbacki pin csynci edge 0 [clearing condition] when 0 is written in cedg after reading cedg = 1 1 [setting condition] when a rising edge is detected on the csynci pin hsynci edge 0 [clearing condition] when 0 is written in hedg after reading hedg = 1 1 [setting condition] when a rising edge is detected on the hsynci pin vsynci edge 0 [clearing condition] when 0 is written in vedg after reading vedg = 1 1 [setting condition] when a rising edge is detected on the vsynci pin only 0 can be written, to clear the flags. the initial value is undefined since it depends on the pin states.
910
911 appendix c i/o port block diagrams c.1 port 1 block diagram r qd d p1npcr c reset r qd p1ndr c reset wp1p r q p1nddr c reset wp1d wp1 internal data bus internal address bus 8-bit pwm pwm output enable pwm output p1n * rp1p rp1 mode 2, 3 mode 1 hardware standby mode 1 expe wp1p: write to p1pcr wp1d: write to p1ddr wp1: write to port 1 rp1p: read p1pcr rp1: read port 1 n = 0 to 7 note: * set priority figure c.1 port 1 block diagram
912 c.2 port 2 block diagrams r qd d p2npcr c reset r qd p2ndr c reset wp2p r q p2nddr c reset wp2d wp2 8-bit pwm pwm output enable pwm output p2n * rp2p rp2 mode 2, 3 mode 1 expe wp2p: write to p2pcr wp2d: write to p2ddr wp2: write to port 2 rp2p: read p2pcr rp2: read port 2 n = 0 to 3 note: * set priority internal data bus internal address bus hardware standby mode 1 figure c.2 port 2 block diagram (pins p20 to p23)
913 r qd d p2npcr c reset r qd p2ndr c reset wp2p r q p2nddr c reset wp2d wp2 8-bit pwm pwm output enable pwm output p2n * rp2p rp2 mode 2, 3 expe iose mode 1 wp2p: write to p2pcr wp2d: write to p2ddr wp2: write to port 2 rp2p: read p2pcr rp2: read port 2 n = 4 to 6 note: * set priority internal data bus internal address bus hardware standby mode 1 figure c.3 port 2 block diagram (pins p24 to p26)
914 r qd d p27pcr c reset r qd p27dr c reset wp2p r q p27ddr c reset wp2d mode 2, 3 wp2 8-bit pwm pwm output enable pwm output timer connection cblank cblank output enable p27 * rp2p rp2 mode 2, 3 expe iose mode 1 wp2p: write to p2pcr wp2d: write to p2ddr wp2: write to port 2 rp2p: read p2pcr rp2: read port 2 note: * set priority internal data bus internal address bus hardware standby mode 1 figure c.4 port 2 block diagram (pin p27)
915 c.3 port 3 block diagram r qd d p3npcr c reset r qd p3ndr c reset wp3p r q p3nddr c reset wp3d wp3 cs iow p3n rp3p rp3 mode 2, 3 mode 1 hardware standby expe hi12e wp3p: write to p3pcr wp3d: write to p3ddr wp3: write to port 3 rp3p: read p3pcr rp3: read port 3 n = 0 to 7 external address read internal data bus host interface data bus figure c.5 port 3 block diagram
916 c.4 port 4 block diagrams d r qd p40dr c reset r q p40ddr c reset wp4d wp4 sci2 txd2/irtxd transmit enable 8-bit timer 0 counter clock input p40 rp4 wp4d: write to p4ddr wp4: write to port 4 rp4: read port 4 internal data bus figure c.6 port 4 block diagram (pin p40)
917 d r qd p41dr c reset r q p41ddr c reset wp4d wp4 8-bit timer 0 8-bit timer output output enable sci2 receive enable rxd2/irrxd p41 rp4 wp4d: write to p4ddr wp4: write to port 4 rp4: read port 4 internal data bus figure c.7 port 4 block diagram (pin p41)
918 d r qd p42dr c reset r q p42ddr c reset wp4d * 1 * 2 wp4 sci2 input enable clock output sda1 output sda1 input transmit enable output enable clock output iic1 8-bit timer 0 reset input p42 rp4 wp4d: write to p4ddr wp4: write to port 4 rp4: read port 4 notes: 1. output enable signal 2. open drain control signal internal data bus figure c.8 port 4 block diagram (pin p42)
919 d r qd p43dr c reset r q p43ddr c reset wp4d wp4 host interface resobf2 (resets hirq11) timer connection hsynci input 8-bit timer 1 counter clock input p43 rp4 wp4d: write to p4ddr wp4: write to port 4 rp4: read port 4 internal data bus figure c.9 port 4 block diagram (pin p43)
920 d r qd p44dr c r q p44dr c reset wp4d wp4 tmo1 output output enable 8-bit timer 1 p44 rp4 wp4d: write to p4ddr wp4: write to port 4 rp4: read port 4 reset host interface resobf1 (resets hirq1) timer connection hsynco output output enable internal data bus figure c.10 port 4 block diagram (pin p44)
921 d r qd p45dr c reset r q p45ddr c reset wp4d wp4 host interface resobf1 (resets hirq12) timer connection csynci input 8-bit timer 1 timer reset input p45 rp4 wp4d: write to p4ddr wp4: write to port 4 rp4: read port 4 internal data bus figure c.11 port 4 block diagram (pin p45)
922 d r qd p4ndr c reset r q p4nddr c reset wp4d wp4 14-bit pwm pwx0, pwx1 output output enable p4n rp4 wp4d: write to p4ddr wp4: write to port 4 rp4: read port 4 n = 6 or 7 internal data bus figure c.12 port 4 block diagram (pins p46, p47)
923 c.5 port 5 block diagrams d r qd p50dr c reset r q p50ddr c reset wp5d wp5 sci0 serial transmit data output enable p50 rp5 wp5d: write to p5ddr wp5: write to port 5 rp5: read port 5 internal data bus figure c.13 port 5 block diagram (pin p50)
924 d r qd p51dr c reset r q p51ddr c reset wp5d wp5 sci0 input enable serial receive data p51 rp5 wp5d: write to p5ddr wp5: write to port 5 rp5: read port 5 internal data bus figure c.14 port 5 block diagram (pin p51)
925 d r qd p52dr c reset r q p52ddr c reset wp5d * 1 * 2 wp5 sci0 input enable clock output scl0 output scl0 input transmit enable output enable clock input iic0 p52 rp5 wp5d: write to p5ddr wp5: write to port 5 rp5: read port 5 notes: 1. output enable signal 2. open drain control signal internal data bus figure c.15 port 5 block diagram (pin p52)
926 c.6 port 6 block diagrams r qd d kmpcr c reset r qd p6ndr c reset wp6p r q p6nddr c reset wp6d wp6 16-bit frt ftci input ftia input ftib input ftid input comparator analog input timer connection 8-bit timers y, x key-sense interrupt input kmimr0, 2, 3, 5 hfbacki input, tmix input, vsynci input, tmiy input, vfbacki input p6n rp6p rp6 wp6p: write to p6pcr wp6d: write to p6ddr wp6: write to port 6 rp6p: read p6pcr rp6: read port 6 n = 0, 2, 3, 5 hardware standby internal data bus figure c.16 port 6 block diagram (pins p60, p62, p63, p65)
927 r qd d kmpcr c reset r qd p61dr c reset wp6p r q p61ddr c reset wp6d wp6 16-bit frt ftoa output output enable timer connection vsynco output output enable a/d converter analog input key-sense interrupt input kmimr1 p61 rp6p rp6 wp6p: write to p6pcr wp6d: write to p6ddr wp6: write to port 6 rp6p: read p6pcr rp6: read port 6 hardware standby internal data bus figure c.17 port 6 block diagram (pin p61)
928 r qd d kmpcr c reset r qd p64dr c reset wp6p r q p64ddr c reset wp6d wp6 timer connection clampo output output enable a/d converter analog input 16-bit frt ftic input key-sense interrupt input kmimr4 p64 rp6p rp6 wp6p: write to p6pcr wp6d: write to p6ddr wp6: write to port 6 rp6p: read p6pcr rp6: read port 6 hardware standby internal data bus figure c.18 port 6 block diagram (pin p64)
929 r qd d kmpcr c reset r qd p66dr c reset wp6p r q p66ddr c reset wp6d wp6 16-bit frt ftob output output enable a/d converter analog input irq6 input kmimr6 other key-sense interrupt inputs irq6 enable p66 rp6p rp6 wp6p: write to p6pcr wp6d: write to p6ddr wp6: write to port 6 rp6p: read p6pcr rp6: read port 6 hardware standby internal data bus figure c.19 port 6 block diagram (pin p66)
930 r qd d kmpcr c reset r qd p67dr c reset wp6p r q p67ddr c reset wp6d wp6 8-bit timer x tmox output output enable a/d converter analog input irq7 input kmimr7 other key-sense interrupt inputs irq7 enable p67 rp6p rp6 wp6p: write to p6pcr wp6d: write to p6ddr wp6: write to port 6 rp6p: read p6pcr rp6: read port 6 hardware standby internal data bus figure c.20 port 6 block diagram (pin p67)
931 c.7 port 7 block diagrams a/d converter analog input p7n rp7: read port 7 n = 0 to 5 rp7 internal data bus figure c.21 port 7 block diagram (pins p70 to p75) a/d converter analog input d/a converter output enable analog output p7n rp7: read port 7 n = 6 or 7 rp7 internal data bus figure c.22 port 7 block diagram (pins p76, p77)
932 c.8 port 8 block diagrams d r qd p80dr c reset r q p80ddr c reset hi12e expe mode 2, 3 wp8d wp8 hif ha0 input p80 rp8 wp8d: write to p8ddr wp8: write to port 8 rp8: read port 8 internal data bus figure c.23 port 8 block diagram (pin p80)
933 d r qd p81dr c reset r q p81ddr c reset wp8d mode 2, 3 expe cs2e hi12e wp8 hif cs2 input hif ga20 output output enable p81 rp8 wp8d: write to p8ddr wp8: write to port 8 rp8: read port 8 internal data bus figure c.24 port 8 block diagram (pin p81)
934 d r qd p8ndr c reset r q p8nddr c reset wp8d wp8 p8n rp8 hif hifsd input (p82 only) wp8d: write to p8ddr wp8: write to port 8 rp8: read port 8 n = 2, 3 internal data bus figure c.25 port 8 block diagram (pins p82, p83)
935 d r qd p84dr c reset r q p84ddr c reset wp8d wp8 sci1 txd1 transmit enable irq3 input irq3 enable p84 rp8 wp8d: write to p8ddr wp8: write to port 8 rp8: read port 8 internal data bus figure c.26 port 8 block diagram (pin p84)
936 d r qd p85dr c reset r q p85ddr c reset wp8d wp8 sci1 input enable serial receive data irq4 input irq4 enable p85 rp8 wp8d: write to p8ddr wp8: write to port 8 rp8: read port 8 internal data bus figure c.27 port 8 block diagram (pin p85)
937 d r qd p86dr c reset r q p86ddr c reset wp8d * 1 * 2 wp8 sci1 input enable clock output scl1 output scl1 input irq5 input irq5 enable transmit enable output enable clock input iic1 p86 rp8 wp8d: write to p8ddr wp8: write to port 8 rp8: read port 8 notes: 1. output enable signal 2. open drain control signal internal data bus figure c.28 port 8 block diagram (pin p86)
938 c.9 port 9 block diagrams d r qd p90dr c reset r q p90ddr c reset wp9d mode 2, 3 expe expe abw ga20 hi12e cs2e wp9 hif ecs2 input a/d converter external trigger input bus controller lwr output p90 rp9 wp9d: write to p9ddr wp9: write to port 9 rp9: read port 9 irq2 input irq2 enable internal data bus figure c.29 port 9 block diagram (pin p90)
939 d r qd p9ndr c reset r q p9nddr c reset wp9d wp9 irq1 input irq0 input irq1 enable irq0 enable p9n rp9 wp9d: write to p9ddr wp9: write to port 9 rp9: read port 9 n = 1 or 2 internal data bus figure c.30 port 9 block diagram (pins p91, p92)
940 d r qd p9ndr c reset r q p9nddr c reset wp9d mode 2, 3 expe expe hi12e wp9 bus controller rd output hwr output as / ios output hif ior input iow input cs1 input p9n rp9 wp9d: write to p9ddr wp9: write to port 9 rp9: read port 9 n = 3 to 5 internal data bus figure c.31 port 9 block diagram (pins p93 to p95)
941 d r s q p96ddr c reset mode 1 wp9d subclock input ?output subclock input enable p96 wp9d: write to p9ddr rp9: read port 9 rp9 internal data bus hardware standby figure c.32 port 9 block diagram (pin p96)
942 d r qd p97dr c reset r q p97ddr c reset wp9d expe wp9 iic0 sda0 input sda0 output transmit enable bus controller input enable wait input p97 rp9 wp9d: write to p9ddr wp9: write to port 9 rp9: read port 9 notes: 1. output enable signal 2. open drain control signal * 1 * 2 internal data bus figure c.33 port 9 block diagram (pin p97)
943 c.10 port a block diagrams d r qd panodr c reset r q panddr c reset mode 2 expe iose wpad wpa rpao rpa a/d converter analog input key-sense interrupt input kmimr n+8 pan wpad: write to paddr wpa: write to paodr rpao: read paodr rpa: read port a n = 0 or 1 hardware standby internal data bus internal address bus figure c.34 port a block diagram (pins pa0, pa1)
944 d r qd panodr c reset r q panddr c reset wpad wpa rpao rpa a/d converter analog input key-sense interrupt input kmimr n+8 pan wpad: write to paddr wpa: write to paodr rpao: read paodr rpa: read port a n = 2 or 3 notes: 1. output enable signal 2. open-drain control signal * 1 * 2 keyboard buffer controller output enable output input hardware standby internal data bus internal address bus mode 2 expe iose figure c.35 port a block diagram (pins pa2, pa3)
945 d r qd panodr c reset r q panddr c reset iics wpad wpa rpao rpa a/d converter input analog input key-sense interrupt input kmimr n+8 pan wpad: write to paddr wpa: write to paodr rpao: read paodr rpa: read port a n = 4 to 7 notes: 1. output enable signal 2. open-drain control signal * 1 * 2 keyboard buffer controller output enable output hardware standby internal data bus internal address bus mode 2 expe iose figure c.36 port a block diagram (pins pa4 to pa7)
946 c.11 port b block diagram d r qd pbnodr c reset (d0, d1) (d0, d1) r q pbnddr c reset expe external address write abw wpbd wpb external address read rpbo rpb pbn wpbd: write to pbddr wpb: write to pbodr rpbo: read pbodr rpb: read port b n = 0, 1 internal data bus host interface resobf3, 4 (reset hirq3, hirq4) figure c.37 port b block diagram (pins pb0 and pb1)
947 d r qd pbnodr c reset (d2, d3) (d2, d3) r q pbnddr c reset expe external address write abw wpbd wpb hif cs3 input cs4 input external address read rpbo rpb pbn wpbd: wpb: rpbo: rpb: n = 2, 3 write to pbddr write to pbodr read pbodr read port b internal data bus figure c.38 port b block diagram (pins pb2 and pb3)
948 d r qd pbnodr c reset (d7 to d4) (d7 to d4) r q pbnddr c reset expe external address write abw wpbd wpb external address read rpbo rpb pbn internal data bus wpbd: wpb: rpbo: rpb: n = 4 to 7 write to pbddr write to pbodr read pbodr read port b figure c.39 port b block diagram (pins pb4 to pb7)
949 appendix d pin states d.1 port states in each processing state table d.1 i/o port states in each processing state port name pin name mcu operating mode reset hardware standby mode software standby mode watch mode sleep mode sub- sleep mode subactive mode program execution state port 1 1 l t keep * keep * keep * keep * a7 to a0 a7 to a0 a7 to a0 2, 3 (expe = 1) t address output/ input port address output/ input port 2, 3 (expe = 0) i/o port i/o port port 2 1 l t keep * keep * keep * keep * a15 to a8 a15 to a8 a15 to a8 2, 3 (expe = 1) t address output/ input port address output/ input port 2, 3 (expe = 0) i/o port i/o port port 3 1 t t t t t t d15 to d8 d15 to d8 d15 to d8 2, 3 (expe = 1) 2, 3 (expe = 0) keep keep keep keep i/o port i/o port port 4 1 t t keep keep keep keep i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 5 1 t t keep keep keep keep i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 6 1 t t keep keep keep keep i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 7 1 t t t t t t input port input port 2, 3 (expe = 1) 2, 3 (expe = 0) port 8 1 t t keep keep keep keep i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 97 1 t t t/keep t/keep t/keep t/keep :$,7 / :$,7 / :$,7 2, 3 (expe = 1) i/o port i/o port 2, 3 (expe = 0) keep keep keep keep i/o port i/o port
950 table d.1 i/o port states in each processing state (cont) port name pin name mcu operating mode reset hardware standby mode software standby mode watch mode sleep mode sub- sleep mode subactive mode program execution state port 96 ? excl 1 clock output t [ddr = 1] h [ddr = 0] t excl input [ddr = 1] clock output excl input excl input clock output/ excl input/ input port 2, 3 (expe = 1) t [ddr = 0] t 2, 3 (expe = 0) port 95 to 93 1 h t h h h h $6 , +:5 , $6 , +:5 , $6 , +:5 , 2, 3 (expe = 1) t 5' 5' 5' 2, 3 (expe = 0) keep keep keep keep i/o port i/o port port 92 to 91 1 t t keep keep keep keep i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 90 1 t t h/keep h/keep h/keep h/keep /:5 / /:5 / /:5 2, 3 (expe = 1) i/o port i/o port 2, 3 (expe = 0) keep keep keep keep i/o port i/o port port a 1 t t keep * keep * keep * keep * i/o port i/o port a23 to a16 2, 3 (expe = 1) a23 to a16/ i/o port a23 to a16/ i/o port 2, 3 (expe = 0) i/o port i/o port port b 1 t t t/keep t/keep t/keep t/keep d7 to d0/ d7 to d0/ d7 to d0 2, 3 (expe = 1) i/o port i/o port 2, 3 (expe = 0) keep keep keep keep i/o port i/o port legend: h: high l: low t: high-impedance state keep: input ports are in the high-impedance state (when ddr = 0 and pcr = 1, mos input pull- ups remain on). output ports maintain their previous state. depending on the pins, the on-chip supporting modules may be initialized and the i/o port function determined by ddr and dr used. ddr: data direction register note: * in the case of address output, the last address accessed is retained.
951 appendix e timing of transition to and recovery from hardware standby mode e.1 timing of transition to hardware standby mode (1) to retain ram contents with the rame bit set to 1 in syscr, drive the 5(6 signal low 10 system clock cycles before the 67%< signal goes low, as shown in figure e.1. 5(6 must remain low until 67%< signal goes low (minimum delay from 67%< low to 5(6 high: 0 ns). stby res t 2 3 0 ns t 1 3 10t cyc figure e.1 timing of transition to hardware standby mode (2) to retain ram contents with the rame bit cleared to 0 in syscr, or when ram contents do not need to be retained, 5(6 does not have to be driven low as in (1). e.2 timing of recovery from hardware standby mode drive the 5(6 signal low at least 100 ns before 67%< goes high to execute a reset. stby res t osc1 t 3 100 ns figure e.2 timing of recovery from hardware standby mode
952
953 appendix f product code lineup table f.1 h8s/2148 series and h8s/2144 series product code lineup preliminary product type product code mark code package (hitachi package code) notes h8s/2148 series h8s/2148 mask rom version standard product (5 v version, 4 v version, hd6432148 hd6432148( *** )fa 100-pin fp (fp-100b) in planning stage 3 v version) hd6432148 (***) te 100-pin tfp (tfp-100b) version with on-chip i 2 c bus interface hd6432148w hd6432148w (***) fa 100-pin fp (fp-100b) (5 v version, 4 v version, 3 v version) hd6432148w (***) te 100-pin tfp (tfp-100b) f-ztat version standard product (5 v/4 v version) hd64f2148 hd64f2148fa20 100-pin fp (fp-100b) under development hd64f2148te20 100-pin tfp (tfp-100b) low-voltage version (3 v version) hd64f2148v hd64f2148vfa10 100-pin fp (fp-100b) under development hd64f2148vte10 100-pin tfp (tfp-100b) h8s/2147 mask rom version standard product (5 v version, 4 v version, hd6432147 hd6432147 (***) fa 100-pin fp (fp-100b) in planning stage 3 v version) hd6432147 (***) te 100-pin tfp (tfp-100b) version with on-chip i 2 c bus interface hd6432147w hd6432147w (***) fa 100-pin fp (fp-100b) (5 v version, 4 v version, 3 v version) hd6432147w (***) te 100-pin tfp (tfp-100b)
954 table f.1 h8s/2148 series and h8s/2144 series product code lineup (cont) preliminary product type product code mark code package (hitachi package code) notes h8s/2144 series h8s/2144 mask rom version standard product (5 v version, 4 v version, hd6432144 hd6432144 (***) fa 100-pin qfp (fp-100b) in planning stage 3 v version) hd6432144 (***) te 100-pin tqfp (tfp-100b) f-ztat version standard product (5 v/4 v version) hd64f2144 hd64f2144fa20 100-pin qfp (fp-100b) hd64f2144te20 100-pin tqfp (tfp-100b) low-voltage version (3 v version) hd64f2144v hd64f2144vfa10 100-pin qfp (fp-100b) under development hd64f2144vte10 100-pin tqfp (tfp-100b) h8s/2143 mask rom version standard product (5 v version, 4 v version, hd6432143 hd6432143 (***) fa 100-pin qfp (fp-100b) in planning stage 3 v version) hd6432143 (***) te 100-pin tqfp (tfp-100b) h8s/2142 mask rom version standard product (5 v version, 4 v version, hd6432142 hd6432142 (***) fa 100-pin qfp (fp-100b) under development 3 v version) hd6432142 (***) te 100-pin tqfp (tfp-100b) f-ztat version standard product (5 v/4 v version) hd64f2142r hd64f2142rfa20 100-pin qfp (fp-100b) under development hd64f2142rte20 100-pin tqfp (tfp-100b) low-voltage version (3 v version) hd64f2142rv hd64f2142rvfa10 100-pin qfp (fp-100b) under development hd64f2142rvte10 100-pin tqfp (tfp-100b) note: ( *** ) is the rom code. the f-ztat version of the h8s/2148 has an on-chip i 2 c bus interface as standard. the f-ztat 5 v/4 v version supports the operating ranges of the 5 v version and the 4 v version. the operating range of the f-ztat low-voltage version will be decided later. the above table includes products in the planning stage or under development. information on the status of individual products can be obtained from hitachis sales offices.
955 appendix g package dimensions figures g.1 and g.2 show the package dimensions of the h8s/2148 series and h8s/2144 series. 0.10 16.0 0.3 1.0 0.5 0.2 16.0 0.3 3.05 max 75 51 50 26 1 25 76 100 14 0 ?8 0.5 0.08 m *0.22 0.05 2.70 *0.17 0.05 0.12 +0.13 ?.12 1.0 0.20 0.04 0.15 0.04 unit: mm *dimension including the plating thickness base material dimension figure g.1 package dimensions (fp-100b)
956 16.0 0.2 14 0.08 0.10 0.5 0.1 16.0 0.2 0.5 0.10 0.10 1.20 max *0.17 0.05 0 ?8 75 51 125 76 100 26 50 m *0.22 0.05 1.0 1.00 1.0 0.20 0.04 0.15 0.04 unit: mm *dimension including the plating thickness base material dimension figure g.2 package dimensions (tfp-100b)


▲Up To Search▲   

 
Price & Availability of HD6432148XXXTE

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X